Hi, I do have a data set with some missing values that appear as blanks. I want to fill these blanks with an NA. How can this be done? Thanks for your help -- View this message in context: http://www.nabble.com/filling-blanks-with-NA-tp21584278p21584278.html Sent from the R help mailing list archive at Nabble.com.
> I do have a data set with some missing values that appear as blanks. Iwant> to fill these blanks with an NA. How can this be done? Thanks for yourhelp Please help us to help you. What form are the data in? Are they in a text file, or are they in R already? What do you mean by 'blanks'? If we can reproduce your problem then we can solve it more easily. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Hi, kayj wrote:> Hi, > > I do have a data set with some missing values that appear as blanks. I want > to fill these blanks with an NA. How can this be done? Thanks for your helpSomething like this?> my.data<-data.frame("var"=c(1,2,5,"",66,4,3,"",67,5,3,2,1,4,32,56,23),stringsAsFactors=F)> my.data$var[1] "1" "2" "5" "" "66" "4" "3" "" "67" "5" "3" "2" "1" "4" "32" "56" "23"> my.data$var[ my.data$var=="" ] <-NA > my.data$var[1] "1" "2" "5" NA "66" "4" "3" NA "67" "5" "3" "2" "1" "4" "32" "56" "23" Kind regards, Kimmo
Try this also: is.na(my.data$var) <- which(my.data$var == "") On Wed, Jan 21, 2009 at 12:33 PM, kayj <kjaja27@yahoo.com> wrote:> > Hi, > > I do have a data set with some missing values that appear as blanks. I want > to fill these blanks with an NA. How can this be done? Thanks for your > help > > -- > View this message in context: > http://www.nabble.com/filling-blanks-with-NA-tp21584278p21584278.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]