4

is it possible to run an ANOVA in r with only means, standard deviation and n-value? Here is my data frame:

q2data.mean <- c(90,85,92,100,102,106)
q2data.sd <- c(9.035613,11.479667,9.760268,7.662572,9.830258,9.111457)
q2data.n <- c(9,9,9,9,9,9)
q2data.frame <- data.frame(q2data.mean,q2data.sq,q2data.n)

I am trying to find the means square residual, so I want to take a look at the ANOVA table.

Any help would be really appreciated! :)

thelatemail
  • 91,185
  • 12
  • 128
  • 188
y3trgfhsfgr
  • 467
  • 8
  • 17
  • 1
    Also, searching google for your exact title of this question gives a link to http://stats.stackexchange.com/questions/95949/one-way-anova-from-summary-data-in-r which points you to: http://www.inside-r.org/packages/cran/rpsychi/docs/ind.oneway.second – thelatemail Oct 02 '14 at 23:28

1 Answers1

9

Here you go, using ind.oneway.second from the rspychi package:

library(rpsychi)
with(q2data.frame, ind.oneway.second(q2data.mean,q2data.sd,q2data.n) )

#$anova.table
#                SS df     MS     F
#Between (A) 2923.5  5 584.70 6.413
#Within      4376.4 48  91.18      
#Total       7299.9 53   
# etc etc

Update: the rpsychi package was archived in March 2022 but the function is still available here: http://github.com/cran/rpsychi/blob/master/R/ind.oneway.second.R (hat-tip to @jrcalabrese in the comments)


As an unrelated side note, your data could do with some renaming. q2data.frame is a data.frame, no need to put it in the title. Also, no need to specify q2data.mean inside q2data.frame - surely mean would suffice. It just means you end up with complex code like:

q2data.frame$q2data.mean

when:

q2$mean

would give you all the info you need.

thelatemail
  • 91,185
  • 12
  • 128
  • 188
  • You are a godsend, thank you! Also: for those without the rpsychi library included the following code before the above script: install.packages("rpsychi") install.packages("gtools") – y3trgfhsfgr Oct 03 '14 at 00:16
  • 1
    @BrettCochrane - `install.packages` should handle getting all the dependencies - no need to install gtools separately. – thelatemail Oct 03 '14 at 01:12
  • 1
    Unfortunately, the `rpsychi` package was archived in March 2022 but the function is still available here: https://github.com/cran/rpsychi/blob/master/R/ind.oneway.second.R – jrcalabrese Jan 28 '23 at 20:10