[R] Replace values in data.frame conditional on another data.frame

Carson Farmer cfarmer at uvic.ca
Wed Mar 5 18:56:35 CET 2008


Dear List,

I am looking for an efficient method for replacing values in a
data.frame conditional on the values of a separate data.frame. Here is
my scenario:
I have a data.frame (A) with say 1000 columns, and 365 rows. Each cell
in the data.frame has either valid value, or NA. I have an additional
data.frame (B) with the same number of rows and columns, with valid
values in all cells. What I would like to do, is replace the cells in B
with NA if and only if the corresponding cell in A is NA.
I have search extensively for a method to do this, and I'm sure that in
the end the solution will be embarrassingly simple, however, any help is
greatly appreciated!

Cheers,

Carson

Apologies if this has been posted twice, we are currently experiencing 
server problems...



More information about the R-help mailing list