0

A simple question.

My Data looks like this

division_name  word
Finance        Good
Commercial     Awesome
Finance        Lovely
Commercial     Support

I am finding pairwise_cor for all possibilites of words above but I get result like:

library(widyr)    
(word_cor <- ps_words %>%
        group_by(word) %>%
        #filter(n() >= 5) %>%
        pairwise_cor(word, division_name) %>%
        filter(!is.na(correlation)))

A tibble: 19,740 x 3
   item1         item2     correlation
   <chr>         <chr>           <dbl>
 1 collaborative excellent       0.745
 2 team          excellent       0.745
 3 ownership     excellent       0.447
 4 support       excellent       0.333

I want to get the above result by group i.e. with division_name

My Data

structure(list(division_name = c("People & Organization", "People & Organization", 
"People & Organization", "People & Organization", "People & Organization", 
"Finance", "People & Organization", "People & Organization", 
"People & Organization", "People & Organization", "Finance", 
"People & Organization", "People & Organization", "Finance", 
"People & Organization", "Finance", "Finance", 
"People & Organization", "Finance", "Finance"
), word = c("excellent", "kick", "start", "nauman", "collaborative", 
"team", "deliverable", "takes", "ownership", "ensure", "support", 
"collaborative", "designing", "planning", "workshop", "deemed", 
"success", "amazing", "knowledge", "sharing")), row.names = c(NA, 
20L), class = "data.frame")
Rana Usman
  • 1,031
  • 7
  • 21
  • I am not able to get this to run. Can you make sure that this is a minimal reproducible example. – adm Dec 19 '19 at 04:51
  • @adm You haven't been able to run because of ``filter(n() >= 5) %>%`` this line. I commented it, it should work now – Rana Usman Dec 19 '19 at 12:43
  • Could you give more information on what you expect from the result? Are you looking to see if Finance and Commercial commonly share words? If so, you could reverse the order of the pairwise_cor() method to achieve that result – JFlynn Dec 19 '19 at 13:36
  • I commented out the filter command and loaded the tidyverse and it gives this error 'Error: `correlation` = value must be a symbol or a string, not a formula' – adm Dec 20 '19 at 15:28

0 Answers0