To: Dick Repasky <drepasky@bio.indiana.edu>
Subject: Re: [R] 0.63 naming list elements
From: Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk>
Date: 18 Nov 1998 17:36:03 +0100
In-Reply-To: Dick Repasky's message of Wed, 18 Nov 1998 10:58:42 -0500 (EST)
Dick Repasky <drepasky@bio.indiana.edu> writes:
> The following used to work (0.62.1 the latest that I used), and now
> it doesn't (0.63.0):
>
>
> force <- vector(mode = "list", length = 1)
> names(force)[1] <- somename
>
> It returns the error:
> Error in "[<-"(NULL, 1) : object is not subsetable
>
>
> You might argue that this approach is unnecessary now that R allows
> subscripts that are out of range (e.g., force<-list(); force[["name"]] <- 42)
> but I changed a lot of code to work as above, and I really don't like
> the idea of reverting.
I don't think it's healthy to try and subset NULL... You could use
just
force <- vector(mode = "list", length = 1)
names(force) <- somename
or, for general length vectors,
force <- vector(mode = "list", length = k)
names(force) <- character(k)
for (i in 1:k)
names(force)[i]<- something.dependent.on(i)
-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._