[R] a pickle with ranks and reals?

John Christie jc at or.psychology.dal.ca
Fri Aug 22 06:44:06 CEST 2003


I predicted that y would increase as x increased.  However, I only made 
the prediction on the ranks of the scores.  The ranks don't correlate 
with predicted.  And, I don't think a regression on the ranks is 
warranted.  However, the actual scores do yield a significant slope for 
b, and a significant R^2 using a linear regression (y is the value and 
x is the predicted rank).  What should my argument be here?  Should I 
have endorsed using the actual scores instead of ranks to begin for 
some reason that doesn't have anything to do with my current result? :)

Oh, on another note, I can use rcorr to get the Spearman correlations, 
but I'd like to be able to just add
the ranks as a column.  I was going to just use order and add a simple 
factor.  But, that doesn't deal with ties correctly.

And, I also wanted to analyze correlations subject by subject and 
compare my two groups.  However, there doesn't seem to be a good way to 
get this.  I tried using "by" with "cor".  However, this requires 
binding x and y which causes cor to return a matrix (if you could pass 
it x and y separate it would just return a number).

given

data frame s
x	y	subj
4	7	harry
5	1	harry
6	9	harry
2	4	steve
3	7	steve
...

i'd like to be able to produce

r	subj
.12	harry
.52	steve
...

any tips?




More information about the R-help mailing list