Skip to content

Obtaining variable's names from a list of variables

1 message · Monsieur Do

#
Thank you for your answers. Problem solved. Eik's cue to all.names(match.call())[-1]?was particularly enlightning!

Do
?
[mailto:E.Vettorazzi at uke.uni-hamburg.de]
from a list of variables
direct way, since
<- list(age,sex)
unnamed list, as can be seen by
#or
sth like
<- list(age=age,sex=sex) # or
<- list(age,sex)
afterwards access them using names().
write your own list function using its call to name the returned object,
17.08.2011 08:46, schrieb Monsieur Do:
have a list of variables,
listVar <- list(age,sex)
looking for a way to either
create a vector c("age","sex") from it, or
the names one by one in a for loop such as these
help much appreciated.
______________________________________________
do read the posting guide
provide commented, minimal, self-contained, reproducible code.
Vettorazzi
f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum
52
Hamburg
++49/40/7410-58243
++49/40/7410-57790