[R] IF function

arun smartpink111 at yahoo.com
Sat Jul 6 00:51:21 CEST 2013


Hi,
May be this helps.  

dat1<- read.table(text="
Col1,Col2
High value,9
Low value,0
High value,7
Low value,0
Low value,0
No data,0
High value,8
No data,0
",sep=",",header=TRUE,stringsAsFactors=FALSE)
dat1$Col2[dat1$Col1=="No data"]<- NA
 dat1
#        Col1 Col2
#1 High value    9
#2  Low value    0
#3 High value    7
#4  Low value    0
#5  Low value    0
#6    No data   NA
#7 High value    8
#8    No data   NA

A.K.


Hello, 

I am an R novice so excuse me if this is woefully straight forward, but I have tried the help files to no avail. 

I am trying to identify cells in 1 column with the value of 'No data', so I can change the values in the next column to 'Null'. 

Currently I am struggling with the data set, as it assigns both 'No data' and 'Low values' as zero which skews my analysis. 

I've tried a number of different attempts but just get the error unexpected symbol ? 




More information about the R-help mailing list