Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get p-values only in significance test in R

I m working on significance tests in R, especially wilcox.test.
I check for example column A of my dataframe data.

wilcox.test(data$A, mu=3)

Afterwards I get a lot of data and text in the console. Is there a posibility to get only the p.value? I hope it will be a bit more clear, when I check the other columns too.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The output is a list, so extract with $ or [[

out <- wilcox.test(data$A, mu=3)
out$p.value

We can get more info by checking the str

str(out)

If there are more columns, loop over the columns with lapply/sapply and extract the p.value

sapply(data[c("A", "B")], function(x) wilcox.test(x, mu = 3)$p.value)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading