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

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Wed, 05 Mar 2008 13:06:54 -0500 (EST)


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



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 05 Mar 2008 - 18:10:15 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 05 Mar 2008 - 19:30:37 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