[R] efficiently replacing values in a matrix

From: Matthew Keller <mckellercran_at_gmail.com>
Date: Wed, 16 Apr 2008 13:52:22 -0600


Hello all,

I should probably know this by now... Anyway:

I have a large matrix (dim(data) is 3000 18000). In each element are one of the following character strings "0/0", "1/1", "1/2", "2/2". I wanted to replace "0/0" with NA and the other three with 0,1,2 respectively. To accomplish just the first of these four steps I did this:

data[data=="0/0"] <- NA

Which is still running after 13 hours. I have 18 GB RAM and running 64 bit R. What is a more efficient way to accomplish this (I've already done it using sed in UNIX - but want to know how to do so in R)? Thanks in advance,

Matt

-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 Apr 2008 - 20:27:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Apr 2008 - 22:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive