Skip to content
Back to formatted view

Raw Message

Message-ID: <386588.68527.qm@web32807.mail.mud.yahoo.com>
Date: 2008-03-05T18:06:54Z
From: John Kane
Subject: Replace values in data.frame conditional on another data.frame
In-Reply-To: <47CEDED3.6020009@uvic.ca>

Try 
bb[is.na(aa)] <- NA

It may be simple but it is not necessarily obvious :)
--- Carson Farmer <cfarmer at uvic.ca> wrote:

> 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...
> 
> ______________________________________________
> 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.
>