[R] efficiently replacing values in a matrix
Matthew Keller
mckellercran at gmail.com
Wed Apr 16 21:52:22 CEST 2008
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
More information about the R-help
mailing list