I am confused by the logic of renaming: # Rename individual list items? Empl<-list(employee="Anna",spouse="Fred") names(Empl)<-c("empl","spo") names(Empl) #[1] "empl" "spo" # worked like a charm... but names(Empl[1])<-"newempl" # no error message, yet .... names(Empl) #[1] "empl" "spo" # where's my newempl??????? If this line names(Empl[1])<-"newempl" was stupid, why is there no error message? --------------------------------------- Dr. Dieter Menne Biomed Software 72074 T?bingen Tel (49) (7071) 52176 FAX (49) (7071) 55 10 46 dieter.menne at menne-biomed.de www.menne-biomed.de -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> From: "Dieter Menne" <dieter.menne at menne-biomed.de> > Date: Thu, 1 Mar 2001 12:30:20 +0100 > > I am confused by the logic of renaming: > > # Rename individual list items? > > Empl<-list(employee="Anna",spouse="Fred") > names(Empl)<-c("empl","spo") > names(Empl) > #[1] "empl" "spo" > # worked like a charm... but > > names(Empl[1])<-"newempl" > # no error message, yet .... > names(Empl) > #[1] "empl" "spo" > # where's my newempl??????? > > > If this line > > names(Empl[1])<-"newempl" > > was stupid, why is there no error message?It wasn't stupid, but it was not what you intended, evidently. Look at> Empl[1]$employee [1] "Anna" That is a list, and you gave it a new name, making a new copy. You did not then reference the new copy. What you intended I think was names(Empl)[1]<-"newempl" which works, but seems not allowed in the R documentation .... -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> To: Prof Brian Ripley <ripley at stats.ox.ac.uk> > Cc: r-help at stat.math.ethz.ch, dieter.menne at menne-biomed.de > Subject: Re: [R] Individual rename of list items > From: Peter Dalgaard BSA <p.dalgaard at pubhealth.ku.dk> > Date: 01 Mar 2001 13:59:32 +0100 > > Prof Brian Ripley <ripley at stats.ox.ac.uk> writes: > > > > > What you intended I think was > > > > names(Empl)[1]<-"newempl" > > > > which works, but seems not allowed in the R documentation .... > > Er, where? I'd say that one is a consequence of general rules for > "complex replacements". How well *they* are documented is another > matter. The R-lang manual has a placeholder consisting of a garbled > bunch of keywords indicating that someone (me, I'm afraid) at some > point was going to write something about something like that....?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. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- r-square for non-linear regression
- Remove columns by name data[-c("subj","drug")]
- as.formula and lme ( Fixed effects: Error in as.vector(x, "list") : cannot coerce to vector)
- Psychometric curves, two altnerative force choice, glm, and budbworms
- quinModel S != R