[R] Removing White spaces with NA

arun smartpink111 at yahoo.com
Wed Apr 2 20:20:52 CEST 2014


Hi,
May be this helps:
dat <- data.frame(Col1=c("A", "", "B","C", "","","D"), stringsAsFactors=FALSE)
is.na(dat) <- dat==''
dat$Col1
#[1] "A" NA  "B" "C" NA  NA  "D" 
A.K.



Hi All, I have a table and a column with values as below Col1
A B
C D I need to replace the Empty cells with the value NA as below
Col1
A
NA
B
C
NA
NA
D I tried a code, which was not working.
Table.name$column.name <- gsub("","NA", table.name$column.name) Can anyone help me with this ?
Thanks and regards,
Praveen




More information about the R-help mailing list