[R] Aggregate

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 6 16:01:33 CET 2000


> Date: Mon, 06 Nov 2000 08:48:04 -0600
> From: "Jagat Sheth" <shethj at epi.wustl.edu>
> 
> Hello to all,
> 
> I recently downloaded R to my PC and am enjoying getting acquainted with it. 
Thank you to everyone involved in the R-project!
> 
> I am interested in doing a log-linear analysis with R on a data set
with dichotomous variables. There are 11 variables (columns) and around
1000 subjects (rows).  How do I aggregate my data, i.e. how do I make a
new dataset that includes the variable giving  the counts for rows with
the same configuration of responses? I know this is possible using the
package 'cfa' (configural frequency analysis, a contributed package in
R) but I can't coerce the output from the cfa command into a data
frame.

I'm not fully sure I understand.  You have a data frame, one row per
subject with 11 columns?  What's the response here?  If one of the
columns is the response (and it is dichotomous) then you can just use
logistic regression without any transformation.  To do a log-linear
analysis using a few of the variables as a joint response you can use
multinom from package nnet on the original data, and it will summarize
the data as you request en route.  To use loglin all you need to do is
use table on the data frame

do.call("table", dataset)

*BUT* I am not sure that is at all appropriate as an analysis.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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