This seems like it should be straightforward but I have a data frame and need to extract the correlation of the scores for each possible pair of id
across trial
(in other words, compare score of id 1 on trial 10 to id 2 on trial 10, id 1 on trial 10 to id 3 on trial 10, and so on. An example data frame is as follows.
id <- c('1','1','1','2', '2', '2', '3', '3', '3')
trial <- c('10','11','12','10', '11', '12', '10', '11', '12')
score<- c('634', '981','101', '621', '31', '124', '827', '404', '92')
d <- data.frame(id, trial, score)
d
id trial score
1 10 634
1 11 981
1 12 101
2 10 621
2 11 31
2 12 124
3 10 827
3 11 404
3 12 92
The result should be a new matrix with correlations of all possible combinations. Ostensibly it's for evaluating score reliability across ids.
The data is about 10000 lines long which causes R to choke up. I've looked in the forums here and tried to figure it out using comb
or outer
but got confused by the syntax. Any help would be much appreciated!