So, I am making my own Wilcoxon Signed-Rank Test function in R and am currently working finding the p-value. I have worked through how to find the test statistic and I was just wondering if there was an easy function that could find the p-value. Any help would be greatly appreciated.
Asked
Active
Viewed 443 times
1 Answers
0
Without a reproducible example, I would use an index like $p.value after the function. For instance the p.value for chi-square test can be obtained using chisq.test(x_value,y_value)$p.value.
Many statistical tests return list
objects with each statistic of interests held within.
If you save the object you can then use str()
to look at what's inside and call it that way.
Here's an example
mydata <- data.frame(x = sample(1:5,20,T), # some fake data
y = sample(1:3,20,T))
wilcox.test(mydata$x,mydata$y) # returns the results
wilcox.test(mydata$x,mydata$y)$p.value # returns the p_value

elliot
- 1,844
- 16
- 45