[R] how to replace <NA> values
jrkrideau at inbox.com
Tue Jan 21 19:07:13 CET 2014
I'm pretty sure that what you have is not what you think you have.
Do a str(Elder1) on the data set and you will see that age is a factor not a numerical variable. Bascally you have a mangled data set from the look of it.
Why would you want to change NA's to 0's?
Kingston ON Canada
> -----Original Message-----
> From: ecokingsly at yahoo.co.in
> Sent: Sun, 19 Jan 2014 11:39:43 -0800 (PST)
> To: r-help at r-project.org
> Subject: [R] how to replace <NA> values
> Dear R community
> I have a large data set contain some empty cells. BecauseB of that,B may
> be I am wrong, <NA> values are produced.
> Now I want replace both empty and <NA> values with zero.
> Elder1 <- data.frame(
> B ID=c("ID1","ID2","ID3","ID6","ID8"),
> B age=c(38,35,"",NA,NA))
> Output I am expecting
> IDB B age
> ID1B 38
> ID2B 35
> ID3B 0
> ID6B 0
> ID8B 0
> In advance I thank your help.
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Send your photos by email in seconds...
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if3
Works in all emails, instant messengers, blogs, forums and social networks.
More information about the R-help