Re: [R] Obtaining variable's names from a list of variables

2011-08-17 Thread Monsieur Do
 : 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

Re: [R] Obtaining variable's names from a list of variables

2011-08-17 Thread Marc Schwartz
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

Re: [R] Obtaining variable's names from a list of variables

2011-08-17 Thread Eik Vettorazzi
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

[R] Obtaining variable's names from a list of variables

2011-08-17 Thread Monsieur Do
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