[R] two easy questions...

Stefano stecalza at tiscalinet.it
Thu Mar 22 14:36:25 CET 2001


Hi all.

1) If I have a dataframe with variable names as follow: PC1 PC2 ... PCn and I want to pass only some of them to a function, e.g.
glm(resp~from PC1 to PC10, PC15, etc.,...)

is there a faster way than simply writing each variable name in the formula?

2) Again, I have a dataframe, say ali.df, with tha following variables: ali1, ali2, ...ali78
I want to sum, for example, ali1+al2+ali7+f rom ali10 to ali20 etc., then from ali4 to ali8, etc. and then put everything in a new dataframe

I'd do somthing like:
 
new.df <- cbind(apply(ali.df[c(1:2,7,10:20)],1,sum), apply(ali.df[4:8],1,sum))   and so on.
Is it the right and only way?


Thanks in advance (and forgive my orrible english...)

Stefano

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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