Hi, Check if this works: n <- 1e7 dat <- data.frame(Col1=c("A", "", "B","C", "","","D",rep('',n)), stringsAsFactors=FALSE)
dat2 <- dat dat[dat==''] <- NA which(dat$Col1=='') #integer(0) #or dat2$Col1[dat2$Col1==''] <- NA which(dat2$Col1=='') #integer(0) A.K. On Wednesday, April 2, 2014 2:20 PM, arun <smartpink...@yahoo.com> wrote: 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 ______________________________________________ R-help@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.