R replace 'xxxxxx' string while reading a text file -


possible duplicate:
replacing character values na in data frame

i reading txt file character , numeric values in each rows. of missing values have been coded xxxxxx in file. want replace them na in data frame. given below soecific row of data frame read in:

mydf[199,]     season  size  speed    mxph    mno2      c1     no3     nh4    opo4     po4 199 winter large medium 8.00000 7.60000 xxxxxxx xxxxxxx xxxxxxx xxxxxxx xxxxxxx       chla1 a1   a2  a3 a4 a5 a6  a7 199 xxxxxxx  0 12.5 3.7  1  0  0 4.9 

i cant seem replace x's na. apprecisted!!!

the simplest approach set xxxxxxx missing while reading data file using na.strings option. here quick example using text connection instead of file:

 txt <- textconnection("1 3 hi xxx\n 2 5 low no")  read.table(txt, na.string="xxx")   v1 v2  v3   v4 1  1  3  hi <na> 2  2  5 low   no 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -