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

Wolfgang RAFFELSBERGER wraff at igbmc.fr
Tue Dec 21 11:54:22 CET 2010


I suppose what you want to do is something like:

dat <- matrix(c(2:13,-9999),nc=4)
dat
dat[dat== -9999] <- 1   # replace the -9999 by 0
dat


Please be careful to think twice what you are doing to you data by changing some values.  Maybe you rather want to replace the -9999 values by NA ?

HTH,
Wolfgang
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC,
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300         Fax (+33) 388 65 3276
wolfgang.raffelsberger at igbmc.fr

________________________________________
De : r-help-bounces at r-project.org [r-help-bounces at r-project.org] de la part de Taiseer Aljazzar [taljazzar at yahoo.com]
Date d'envoi : mardi 21 décembre 2010 09:59
À : r-help at r-project.org
Objet : [R] replace values of a table !!!

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.

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