Skip to content
Back to formatted view

Raw Message

Message-ID: <4289AEC3.26104.416584@localhost>
Date: 2005-05-17T06:43:47Z
From: PIKAL Petr
Subject: NA erase your data trick
In-Reply-To: <Pine.LNX.4.58.0505170134070.5648@ls02.fas.harvard.edu>

Hi

Maybe

tcn5[tcn5 == -9] <- NA

if tcn5 is matrix


> mat<-matrix(rnorm(100),10,10)
> mat[5,6:7]<- -9
> mat[mat == -9]<-NA

Read some intro on data manipulation, it helps you to avoid 
thinking in loops

Cheers
Petr

On 17 May 2005 at 1:37, Anders Schwartz Corr wrote:

> 
> Oops,
> 
> I just erased all my data using this gizmo that I thought would
> replace -9 with NA.
> 
> A) Can I get my tcn5 back?
> 
> B) How do I do it right next time, I learned my lesson, I'll never do
> it again, I promise!
> 
> Anders Corr
> 
> > for(i in 1:dim(tcn5)[2]){         ##for the number of columns
> +     for(n in 1:dim(tcn5)[1]){     ##for the number of rows
> +         tcn5[is.na(tcn5[n,i]) | tcn5[n,i] == -9] <- NA
> +
> +         }
> + }
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz