0

im searching a r package that enables me to compute Goodman and Kruskal's gamma correlations within each subject. I have 2 variables with 16 items each, which I would like to correlate per subject.

So far I used the Hmisc package and the rcorr.cens() function. However, the function creates an correlation overall subject and I failed to adapt the code to get a correlation for each subject... Thats how I tried so far....

        ```Gamma_correlation <- dataframe %>% 
           group_by(Subject) %>% 
           rcorr.cens(dataframe$Variable_1,                          
                      dataframe$Variable_2, 
                      outx = TRUE)[2]```
  • a [mcve] would be very helpful. You can probably achieve what you want with `rcorr.cens` suitably wrapped in a for loop ... – Ben Bolker May 29 '20 at 15:23
  • thanks for your advise. I was also thinking about creating a for loop... but I wanted to check first if there is any package I havent thought about, that would resolve the problem for me. – Florian Bühler Jun 02 '20 at 06:59

1 Answers1

1

You could possibly achieve this by removing the dataframe$ and just keeping the variable names. Hmisc also seems to mask the summarize function of the dplyr, so you can put the rcorr.cens chunk in dplyr::summarize().

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
Ebru Ger
  • 11
  • 1