[R] substituting values
TEMPL Matthias
Matthias.Templ at statistik.gv.at
Thu Mar 9 14:51:43 CET 2006
One way:
A <- matrix(round(rnorm(20)), ncol=4)
A[2,1] <- "x"
A[which(A == "x", arr.ind=TRUE)] <- NA
A <- matrix(as.numeric(A), ncol=dim(A)[2])
Best,
Matthias
> -----Ursprüngliche Nachricht-----
> Von: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] Im Auftrag von
> Stefan Semmeling
> Gesendet: Donnerstag, 09. März 2006 14:32
> An: r-help at stat.math.ethz.ch
> Betreff: [R] substituting values
> Vertraulichkeit: Persönlich
>
>
> dear list,
>
> i have a matrix with missing values like
>
> 1 2 3 4 x
> x 2 2 2 2
> 2 2 2 x 2
>
> the x stands for the missing value.
> i have to substitute it to NA
>
> substitute or replace didn´t work out, as they are for vectors only
>
> however matrix[,i] also didn´t work.
>
> can anybody tell me, who i can change these values easily?
>
> thanks stefan
>
> [[alternative HTML version deleted]]
>
>
More information about the R-help
mailing list