[R] using names inside a loop

Alberto Murta amurta at ipimar.pt
Thu Jan 24 18:59:09 CET 2002


I expected that something like

> for(i in names(my.data.frame)){j <- as.name(i); print(my.data.frame$j)}

should work in R (and S). There's always the possibility of using  

> for(i in names(my.data.frame)){print(my.data.frame[,i])}

but can someone someone tell me why doesn't the 1st option work also?
Thanks

Alberto

-- 
                           Alberto G. Murta                      
           IPIMAR - Institute of Fisheries and Sea Research
            Avenida de Brasilia, 1449-006 Lisboa, Portugal       
Tel:+351 213027062; Fax:+351 213015849; http://www.ipimar.pt/pelagicos/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list