First of all I thank all the friends.

Though I  have written zero to replace NA in  previous email, I will replace with extreme value (99999).



On Tuesday, 21 January 2014 7:05 AM, jwd [via R] <ml-node+s789695n4683894h41@n4.nabble.com> wrote:
  
On Sun, 19 Jan 2014 11:39:43 -0800 (PST) 

kingsly <[hidden email]> wrote: 


________________________________
The age variable is being read in as a factor because of the 
"".  If you were to replace it with NA, the type becomes numerical: 

Before replacement: 

str(Elder1) 
'data.frame':   5 obs. of  2 variables: 
 $ ID : Factor w/ 5 levels "ID1","ID2","ID3",..: 1 2 3 4 5 
 $ age: Factor w/ 3 levels "","35","38": 3 2 1 NA NA 

Notice that the "" is treated as a factor level. 

After: 

str(Elder1) 
'data.frame':   5 obs. of  2 variables: 
 $ ID : Factor w/ 5 levels "ID1","ID2","ID3",..: 1 2 3 4 5 
 $ age: num  38 35 NA NA NA 

SO, the question, is what do you want to do with that column?  An "NA"
value tells you honestly that the information is missing.  Replacing it 
with a zero can be misleading and can bias some basic parameter 
estimates. 

After you know how you want to treat the data in that field, you may 
have a better idea of how to handle the missing data. 

JWD 

______________________________________________ 
[hidden email] 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. 




________________________________

If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683894.html  
To start a new topic under R help, email ml-node+s789695n789696h3@n4.nabble.com 
To unsubscribe from R help, click here.
NAML



--
View this message in context: http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683896.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]


