: Re: [R] Obtaining variable's names
from a list of variables
>
> Hi,
> there is no
direct way, since
> listVar
<- list(age,sex)
> creates a
unnamed list, as can be seen by
> names(listVar)
#or
> str(listVar)
>
> You can do
sth like
> listVar
<- list(age=age,sex=se
On Aug 17, 2011, at 1:46 AM, Monsieur Do wrote:
> Say I have a list of variables,
>
> listVar <- list(age,sex)
>
> I am looking for a way to either
>
> 1- create a vector c("age","sex") from it, or
> 2- get the names one by one in a for loop such as these
>
> a) for (i in 1:length(listVa
Hi,
there is no direct way, since
listVar <- list(age,sex)
creates a unnamed list, as can be seen by
names(listVar) #or
str(listVar)
You can do sth like
listVar <- list(age=age,sex=sex) # or
listVar2 <- list(age,sex)
names(listVar2)<-c("age","sex")
and afterwards access them using names().
Or yo
Say I have a list of variables,
listVar <- list(age,sex)
I am looking for a way to either
1- create a vector c("age","sex") from it, or
2- get the names one by one in a for loop such as these
a) for (i in 1:length(listVar)) rownames(result)[i] <- ???
b) for(i in listVar) print (vari
4 matches
Mail list logo