Reputation: 317
test()` in Rand it gives me back the x-squared and the p-value.
Now I want to take the p-value and according to the reading proceed with my program. How can I extract the p-value from the result of the output of chisq.test()
?
Upvotes: 2
Views: 1684
Reputation: 779
Performing a \Chi^2 test on the vectors x and y and storing it in 'results'
results<-chisq.test(x,y)
you can then retrieve the estimated parameters as
results[1], results[3], ... or results$statistic, results$p.value, ...
where the last part is of course the most self-describing way to do it.
Remember to cast the results to numeric values, that is
as.numeric(results[1])
HTH,
Christian
Upvotes: 3
Reputation: 66874
chisq.test(x)$p.value
You can see what an object holds using str
:
str(chisq.test(x))
Upvotes: 5