I want to calculate the correlation between sf and pf only for values correspond to half of (highest values) P
P=c(1,6,5,6,2,8,5)
sf=c(1,2,6,6,4,5,5)
Pf=c(1,6,5,8,4,8,5)
cor(sf,Pf)
Any help please?
I want to calculate the correlation between sf and pf only for values correspond to half of (highest values) P
P=c(1,6,5,6,2,8,5)
sf=c(1,2,6,6,4,5,5)
Pf=c(1,6,5,8,4,8,5)
cor(sf,Pf)
Any help please?
If I understand you correctly, then this should do the trick
cor(sf[P > median(P)], Pf[P > median(P)])
Since you want the top 50% of P
, this corresponds to the values of P greater than the median.