Judith Flores <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> Sorry, I hit the send botton by accident. Here is my > code so far: > > dat<-read.csv('myfile.csv', na.strings="") > dat[is.na(dat]<-'N' > > But it doesn't replace the <NA> for the letter 'N'. > > What happens when you just type: dat[is.na(dat)] #? My guess is that you don't have any, since na.strings="" told read.table that there were no values that should be assigned <NA>. It is possible to have a value of "NA" that is not <NA>. > x <- c("NA", 1 , 2) #NA is not <NA> > is.na(x) [1] FALSE FALSE FALSE > txt <- "nnn 1 2 3 4 5" > xt<- read.table(textConnection(txt), header=FALSE) > xt V1 V2 V3 V4 V5 V6 1 nnn 1 2 3 4 5 > xt<- read.table(textConnection(txt), header=FALSE,na.strings="nnn") > xt V1 V2 V3 V4 V5 V6 1 NA 1 2 3 4 5 #That is a TRUE >NA> > is.na(xt) V1 V2 V3 V4 V5 V6 [1,] TRUE FALSE FALSE FALSE FALSE FALSE > xt[is.na(xt)] <- "N" > xt V1 V2 V3 V4 V5 V6 1 N 1 2 3 4 5 -- David Winsemius ______________________________________________ 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.