Search code examples
rfactorial

c function error in R


I am trying to conduct factorial ANOVA test on R for 2*2 factors ('Sex', 'Avatar', both between-subject factors) and it keeps showing error

formal argument "between" matched by multiple actual arguments

library(ez)
m = ezANOVA(dv=Positives, between=Sex, between=Avatar, wid=Subject, data=avt)

Assignment tip was:

Pass both Sex and Avatar as the between parameter using a vector created with the "c" function.

I tried to use c(between = Sex, between = Avatar), it doesn't work either.

Please, may I ask for help on this code? Many thanks!


Solution

  • In such cases it is always worth trying to RTM.

    It says

    If a single value, may be specified by name alone; if multiple values, must be specified as a .() list.

    see https://cran.r-project.org/web/packages/ez/ez.pdf

    The manual also has an example, which goes like this:

    #Run an ANOVA on the mean correct RT data.
    rt_anova = ezANOVA(
        data = ANT[ANT$error==0,]
        , dv = rt
        , wid = subnum
        , within = .(cue,flank)
        , between = group
    )
    

    So you should probably try

    m = ezANOVA(dv=Positives, between=.(Sex, Avatar), wid=Subject, data=avt)