[R] ANOVA: New User question

4 views
Skip to first unread message

Mackay Peter

unread,
Sep 16, 2008, 4:30:27 AM9/16/08
to r-h...@r-project.org

I am a relatively new user of R, and have a question on ANOVA

I have a sumamrised data set of the form (data dummy only)

Cell Treatment Total Resp
1 1 25000 682
1 0 35000 600
2 1 5000 40
2 0 4000 30
3 1 36000 2400
3 0 400 250

and wish to perform ANOVA. Because its sumamrised I need to tell R to
treat the data as if I had all the individual rows. Otherwise, I only
end up with 1 or 2 DF.

I know in SAS, ANOVA has a 'FREQ' option ... does something similar
exist in R?

Kind Regards
Peter


***********************************************************
CAUTION: This email and files included in its transmission
are solely intended for the use of the addressee(s) and may
contain information that is confidential and privileged.
If you receive this email in error, please advise us
immediately and delete it without copying the contents
contained within. Woolworths Limited (including its group
of companies) do not accept liability for the views
expressed within or the consequences of any computer
viruses that may be transmitted with this email. The
contents are also subject to copyright. No part of it
should be reproduced, adapted or transmitted without the
written consent of the copyright owner.
***********************************************************

[[alternative HTML version deleted]]

______________________________________________
R-h...@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.

Peter Dalgaard

unread,
Sep 16, 2008, 5:28:14 AM9/16/08
to Mackay Peter, r-h...@r-project.org
Mackay Peter wrote:
> I am a relatively new user of R, and have a question on ANOVA
>
> I have a sumamrised data set of the form (data dummy only)
>
> Cell Treatment Total Resp
> 1 1 25000 682
> 1 0 35000 600
> 2 1 5000 40
> 2 0 4000 30
> 3 1 36000 2400
> 3 0 400 250
>
> and wish to perform ANOVA. Because its sumamrised I need to tell R to
> treat the data as if I had all the individual rows. Otherwise, I only
> end up with 1 or 2 DF.
>
> I know in SAS, ANOVA has a 'FREQ' option ... does something similar
> exist in R?
>
>
An explicit rep(x, count) does the same as the FREQ option. Without the
group standard deviations, neither will produce anything useful, though.

If you do have SDs, there's a technique used in my book

fake.trypsin<-local({
xrnorm<-function(n,xbar,s){
t<-rnorm(n);t<-(t-mean(t))/sd(t);xbar+s*t}
g.1<-xrnorm(32,128,50.9)
g.2<-xrnorm(137,152,58.5)
g.3<-xrnorm(38,194,49.3)
g.4<-xrnorm(44,207,66.3)
g.5<-xrnorm(16,215,60)
g.6<-xrnorm(4,218,14)
trypsin<-c(g.1,g.2,g.3,g.4,g.5,g.6)
grp<-rep(1:6,c(32,137,38,44,16,4))
grpf<-factor(grp)
data.frame(trypsin,grp,grpf)})

or you can use the equivalent of this SAS trick:

http://ssc.utexas.edu/consulting/answers/sas/sas48.html

--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dal...@biostat.ku.dk) FAX: (+45) 35327907

Reply all
Reply to author
Forward
0 new messages