Skip to content
Back to formatted view

Raw Message

Message-ID: <OF8A9DC144.FDD60C36-ONC1257800.0038DC52-C1257800.0039740F@precheza.cz>
Date: 2010-12-21T10:26:56Z
From: PIKAL Petr
Subject: Odp:  replace values of a table !!!
In-Reply-To: <478628.1266.qm@web110402.mail.gq1.yahoo.com>

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.