Message-ID: <OF5C84429F.5A43D7CF-ON802574C6.004E0760-802574C6.004E8321@hsl.gov.uk>
Date: 2008-09-16T14:20:16Z
From: Richard Cotton
Subject: HI
In-Reply-To: <20080916140127.GA9906@hsl.gov.uk>
> > Does anyone know an easy way to convert all the zero values in a
> imported csv table into NA's
>
> Depends on the data structure you gave your imported table. In a
> single numeric vector (named, say, vec), the syntax is
>
> is.na(vec[vec==0]) <- TRUE
That throws errors for me. An alternative is
vec[vec==0] <- NA
This also works for data frames, e.g.
df <- data.frame(a=c(1,2,3,0,3,4,0,5,2), b=c(1,0,0,1,1,0,1,1,0))
df[df==0] <- NA
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}