Message-ID: <200107261440.JAA17566@definetti.uark.edu>
Date: 2001-07-26T14:40:21Z
From: Giovanni Petris
Subject: replacing values in a vector
In-Reply-To: <3B600234.5A4225A@psy.uni-muenchen.de> (message from Sven Garbade on Thu, 26 Jul 2001 13:42:44 +0200)
You should assign the result of replace back to n:
n <- replace(n, which(is.na(v)), NA)
Giovanni
--
__________________________________________________
[ ]
[ Giovanni Petris GPetris at uark.edu ]
[ Department of Mathematical Sciences ]
[ University of Arkansas - Fayetteville, AR 72701 ]
[ Ph: (501) 575-6324, 575-8630 (fax) ]
[ http://definetti.uark.edu/~gpetris/ ]
[__________________________________________________]
> Date: Thu, 26 Jul 2001 13:42:44 +0200
> From: Sven Garbade <garbade at psy.uni-muenchen.de>
> X-Accept-Language: en
> Sender: owner-r-help at stat.math.ethz.ch
> Precedence: SfS-bulk
> Content-Type: text/plain; charset=us-ascii
> Content-Length: 649
>
> Hi all,
>
> there is a vector v with several NAs. I want to create a new vector n of
> the same length as v and the same NAs as in v and tried this:
>
> n <- vector(length=length(v), mode="numeric")
> replace(n, which(is.na(v)), NA)
>
> but this does't work, all values in n are 0. What went wrong?
>
> Thanks, Sven
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._