[R] summary statistics into table/data base, many factors to analyse

Petr PIKAL petr.pikal at precheza.cz
Fri Nov 21 14:44:32 CET 2008


Hi

r-help-bounces at r-project.org napsal dne 21.11.2008 11:50:52:

> Dear list,
> 
> thanks to your help I managed to find means of analysing my data.
> 
> However, the whole data set contains 264 variables. Of which some are
> factors, others are not. The factors tend to be grouped, e.g. 
> data$f1304 to data$f1484 and data$f3204 to data$5408. 
> 
> But there are other types of variables in the data set as well, 
> e.g. data$f1504. 
> 
> Not every spot is taken, i.e data$f1345 to data$1399 might not exist
> in the data set. 
> 
> The solution "summaryBy" works for cross analysis, of which there is
> a handful. So I am not worried here.
> 
> The solution from Jorge is fine. 
> However, I am trying to get my head around how to efficiently
> reduce my data set to the dependet variable and the factors such that
> the solution is applicable.
> 
> Having to type each variable into
> my.reduced.data <- cbind(my.data$f1001, my.data$1002, my.data$1003...
> is an obvious option, but does not seem to be the most efficient one.

Maybe not so obvious. 
How did you get your data into R? By some read.* command? Then it shall be 
data frame with appropriate column type.

see str(mydata)

and you can choose only columns you really want by

mydata[, select.some.columns]

If your data is a list (see Intro manual for data types and its 
properties), then the transformation to data frame depends partly on how 
it looks like and if it has the same number of values.

do.call("cbind", mydata) shall combine all vectors in mydata however it 
will convert them to unique type as cbind produce matrix which has to have 
only one type of data.

If all variables have same length

do.call("data.frame", mydata)

will produce data frame and all variables shall be preserved in their 
respective type.

Regards
Petr


> 
> Are there better ways to go about?
> 
> Thanks,
> Gerit
> -- 
> Sensationsangebot nur bis 30.11: GMX FreeDSL - Telefonanschluss + DSL 
> für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list