Hi!

Would anyone know how to generate a list of variable names from a data frame by 
the class of the variable? 

I have large tables with different numbers of columns and am trying to script 
some rote analyses. There are several categorizing variables (factors) and many 
response variables (integers and numeric). I want to extract a list of 
classifier column names in one list and response variable names in another 
list, then run for-loops to calculate various statistics on the response 
variables in terms of the classifier variables. I thought something like this 
might work (but didn't):


tmp<-dataframe
for (i in 1:length(tmp)){
        if(class(tmp[[i]]=="factor") else tmp[[i]]<-NULL
}

factorlist<-names(tmp)

...

One problem is that the scope of the counter changes as I drop columns, but 
there seems to be other problems as well

Any suggestions would be welcome. Thanks!

Jon

Soli Deo Gloria

Jon Erik Ween, MD, MS
Scientist, Kunin-Lunenfeld Applied Research Unit 
Director, Stroke Clinic, Brain Health Clinic, Baycrest Centre
Assistant Professor, Dept. of Medicine, Div. of Neurology
    University of Toronto Faculty of Medicine

Kimel Family Building, 6th Floor, Room 644 
Baycrest Centre
3560 Bathurst Street 
Toronto, Ontario M6A 2E1
Canada 

Phone: 416-785-2500 x3648
Fax: 416-785-2484
Email: jw...@klaru-baycrest.on.ca


Confidential: This communication and any attachment(s) may contain confidential 
or privileged information and is intended solely for the address(es) or the 
entity representing the recipient(s). If you have received this information in 
error, you are hereby advised to destroy the document and any attachment(s), 
make no copies of same and inform the sender immediately of the error. Any 
unauthorized use or disclosure of this information is strictly prohibited.




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to