[R] use of the 'by' command & converting SPSS ANOVA/GLM syntax into R syntax
Duncan Murdoch
murdoch at stats.uwo.ca
Mon Nov 21 02:06:38 CET 2005
On 11/20/2005 3:44 PM, Bob Green wrote:
> I have two questions I would appreciate assistance with:
>
> (1) I believe "by" is the command used to split a file. In the following
> example, "mydat" is the dataframe , "group" the variable I want to split
> the analysis by & "WK1FREQ,WK2FREQ" the variables
>
> attach(mydat)
> by (GROUP)
> cor.test (WK1FREQ,WK2FREQ)
>
> I have also tried: (by (GROUP) cor.test (WK1FREQ,WK2FREQ))
I think you want
by(mydat, mydat$GROUP, function(subset) cor.test(subset$WK1FREQ,
subset$WK2FREQ))
>
> (2)
>
> I also wanted to run the following analyses, written in SPSS syntax. I have
> searched the R archives and gather I may need to use lm instead of glm, but
> got lost.
>
> UNIANOVA
> avfreq BY sex WITH blik
> /METHOD = SSTYPE(3)
> /INTERCEPT = INCLUDE
> /EMMEANS = TABLES(OVERALL)
> /EMMEANS = TABLES(sex)
> /PRINT = DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
> /CRITERIA = ALPHA(.05)
> /DESIGN = blik sex blik*sex .
>
> GLM
> avmth3fq avfreq BY SEX
> /WSFACTOR = timex 2 Polynomial
> /METHOD = SSTYPE (3)
> /PRINT = DESCRIPTIVE ETASQ TEST(MMATRIX) HOMOGENEITY
> /CRITERIA = ALPHA (.05)
> /WSDESIGN = timex
> /DESIGN = sex .
Sorry, I don't know SPSS syntax, so I can't help you with this one.
Duncan Murdoch
>
> Any assistance with either of these enquiries is most appreciated.
>
> Bob
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list