juliasilge / widyr

Widen, process, and re-tidy a dataset
http://juliasilge.github.io/widyr/
Other
327 stars 29 forks source link

pairwise_cor() and p value of correlations #46

Open ghost opened 1 year ago

ghost commented 1 year ago

Dear, Thank you for this package, which I am using to measure correlations between words. Pairwise co-occurrence between words that co-occur in the same posts from social media. However, I want to extract the p-value of these correlations, I wonder how I can use the package to do that. Thank you David for this tutorial : https://www.youtube.com/watch?v=mApnx5NJwQA Here is the code for my correlations (line is the id of the post) correlatee <- data2 %>% group_by(word) %>% pairwise_cor(word, line, sort = TRUE, upper = FALSE) Thank you

juliasilge commented 1 year ago

In its current implementation, pairwise_cor() only computes a correlation, like stats::cor():

https://github.com/juliasilge/widyr/blob/a6696d64ec7a21b23196a6024e06e3a937ae2a93/R/pairwise_cor.R#L64-L68

It does not do a test like stats::cor.test(). This is sort of related to #36, where you are interested in a pairwise computation of something beyond the main quantity returned. We could think through how to return other, more complete info in the tidy format we use in this package.

In the meantime, I suggest that you use cor.test() together with broom and purrr for a more manual and customizable approach.