[R] Question regarding to replace NA

2010-11-09 Thread Kate Hsu
Dear r-users, Basically, I have a data as follows, data S s1 s2 s3 s4 s5 prob obs num.strata 1 N N N N N N 0.108 32 NA 2 Y N N N N Y 0.0005292 16 NA 3 NNNYN N N N Y N 0.0005292 24 NA 4 NNNYY N N N Y Y 0.0259308 8 1

Re: [R] Question regarding to replace NA

2010-11-09 Thread Joshua Wiley
Hi Kate, is.na() does not work on entire data frames. You just need to specify the column, for example: data[is.na(data[, 8]), 8] - 0 if the NAs were in column 8. Best regards, Josh On Tue, Nov 9, 2010 at 9:33 AM, Kate Hsu yhsu.rh...@gmail.com wrote: Dear r-users, Basically, I have a

Re: [R] Question regarding to replace NA

2010-11-09 Thread Phil Spector
Kate - As the error message indicates, num.strata is a factor. This can occur when you're reading in data and R encounters a non-numeric value which was not specified in the na.strings= argument to read.table. To do what you want, you'll need to convert it to a character variable first:

Re: [R] Question regarding to replace NA

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 9:39 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Kate, is.na() does not work on entire data frames. whoops, I did not mean that. is.na() has a data frame method, but there are assignment issues (as you saw) when you use it that way. Josh [snip]

Re: [R] Question regarding to replace NA

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 9:43 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: On Tue, Nov 9, 2010 at 9:39 AM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Kate, is.na() does not work on entire data frames. whoops, I did not mean that.  is.na() has a data frame method, but there are assignment