[R] Individual rename of list items

Peter Dalgaard BSA p.dalgaard at pubhealth.ku.dk
Thu Mar 1 14:24:52 CET 2001


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> ?names says
> 
>      `names' is a generic accessor function to the `names' attribute of
>      an R object, typically a `vector'. The first form prints the names
>      of the observations and the second sets the names. In this case,
>      `value' must be a vector of character strings of the same length
>      as `x'.
> 
> which seems fairly clearly to disallow my example.

Mnnno....

I think the rules would say that

 names(x)[1]<-"HEY"

is evaluated in steps as 

tmp<-names(x)
tmp[1] <- "HEY"
names(x) <- tmp

and the last line matches the requirements. Or, it is functionally
equivalent to

x <- "names<-"(x,"[<-"(names(x),1,"HO"))

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at 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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list