0

I have years between 1980 to 2000 where each year has repetitive id's. So I'm trying to calculate a correlation coefficient of one variable between id1 and id2 through the years. So I try the following code;

\ddply(df, .(id), summarise, "corr" = cor(x1, x2 = "spearman"))\

However what I would like to calculate is similar to following;

\ddply(df, .(id), summarise, "corr" = cor(x1|id1, x1|id2 = "spearman"))\

So, I can have between-id correlations of x1?

  • Hello @Cemil Faruk. Welcome on SO! Please, provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so that other SO users can help you in the best way. – lovalery Oct 28 '21 at 13:34

0 Answers0