Extract p-value from aov Extract p-value from aov r r

Extract p-value from aov


Here:

summary(test)[[1]][["Pr(>F)"]][1]


since the suggest above didn't work for me this is how i managed to solve it:

sum_test = unlist(summary(test))

then looking at the names with

names(sum_test)

i have"Pr(>F)1" and "Pr(>F)2", when the first it the requested value, so

sum_test["Pr(>F)1"]

will give the requested value


I know this is old but I looked around online and didn't find an explanation or general solution and this thread is one of the first things that comes up in a Google search.

Aniko is right, the easiest way is looking in summary(test).

tests <- summary(test)str(tests)

That gives you a list of 1 for an independent measures aov object but it could have multiple items with repeated measures. With the repeated measures each item in the list is defined by the error term for the item in the list. Where a lot of new people get confused is that if it's between measures the one lone list item isn't named. So, they don't really notice that and don't understand why using a typical selector doesn't work.

In the independent measures case something like the following works.

tests[[1]]$'Pr(>F)'

In repeated measures it's similar but you could also use named items like...

myModelSummary$'Error: subject:A'[[1]]$'Pr(>F)'

Note there I still had to do that list selection because each one of the list items in the repeated measures model is again a list of 1.