Re: [R] return NA

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Thu 30 Jun 2005 - 05:56:23 EST


You need to use is.na(df1[,i]) to test for NA.

Andy

> From: dscully@fd9ns01.okladot.state.ok.us
>
>
>
>
>
> A<-c(1,2,NA,7,5)
> B<-c(3,4,1,4,1)
> C<-c(6,5,6,NA,9)
> D<-c(8,7,4,6,2)
> df1<-cbind(A,B,C,D)
> for(i in seq(1,ncol(df1)-1, by=2)) {
> ifelse(df1[,i]=="NA",df1[,i+1]=="NA",df1[,] ) }
>
>
> Tried several variations but none worked. I wish to find any NA's in
> column's 1 or 3 and change the numerical value to the right of the "
> NA"'s . In this case I wish to replace the 1 and 6
> respectively with "NA".
> Any help would be appreciated.
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 30 06:01:09 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:07 EST