[R] Odp: replace values of a table !!!

Petr PIKAL petr.pikal at precheza.cz
Tue Dec 21 11:26:56 CET 2010


Hi

r-help-bounces at r-project.org napsal dne 21.12.2010 09:59:31:

> Dear all,
> 
> Dear all,
> 
> I am a relatively new user.
> I have an ascii file with 550 rows and 400 columns. The file contain 
values 
> ranging from 1 to 2000 and some values with -9999.
> 
> I want to generate a new file where the -9999 values are replaced with 0 

> values, the other values with the 1.0 value.

Do you want to use R for it? If yes you can read the file and set -9999 as 
missing value
see ?read.table

further on you can

change not NA values to 1 by

your.data[!is.na(your.data)] <- 1

and NA values to 0 by

your.data[is.na(your.data)] <- 0

Regards
Petr

> 
> What should I do,
> 
> Thanks
> Taiseer
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list