Message-ID: <199901081104.MAA07882@sophie.ethz.ch>
Date: 1999-01-08T11:04:16Z
From: Martin Maechler
Subject: avoiding (another) error
In-Reply-To: <Pine.LNX.3.96.990108102540.7143A-100000@iamgygax.unizh.ch> (message from Lorenz Gygax on Fri, 8 Jan 1999 10:34:29 +0100 (MET))
>>>>> "Lorenz" == Lorenz Gygax <lgygax at access.unizh.ch> writes:
Lorenz> Dear all, Many thanks to all who always so quickly respond with
Lorenz> helpful hints!
Lorenz> Currently I am working with R 0.63.1 on SuSE 5.2 which I
Lorenz> installed this morning within about half an hour: my deepest
Lorenz> compliments to the developpers! (I had still 0.62.2 before.)
Lorenz> This time I am trying the following:
> xy <- list (a= c (1, 2, NA), b= c (2, 3))
> list.name <- "xy"
> get (list.name)$a [is.na (get (list.name)$a)] <- 0
Error: couldn't find function "get<-"
> xy
$a
[1] 1 2 0
$b
[1] 2 3
Lorenz> So obvisouly R *does* what I would like it to do.
But it shouldn't and this is the real bug here!
Lorenz> How can I get
Lorenz> it to do it without the error? The problem is that I need to do
Lorenz> this within a function.
One way (maybe the most elegant?) :
xy <- list (a= c (1, 2, NA), b= c (2, 3)); list.name <- "xy"
A <- .Alias(get(list.name))
A$a[is.na(A$a)] <- 0
xy $ a # -> 1 2 0
##-- would this be a convincing example for .Alias() ??
--
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._