Hi
On 27 Aug 2003 at 20:32, John Christie wrote:
> OK, I am try to produce an array of ranks. I have a set of data (s)
> that looks like this
>
> rt subj
> 312 dave
> 467 dave
> 411 dave
> 383 kim
> 398 kim
> ...
>
> Now I want to make a column that is an array of the ranks of rt by
> subject. The closest of gotten is using the following.
>
> r <- by (s, s$subj, function(d) rank(d[1]))
>
> This gets the data out with ranks but I cannot figure out how to
> easily extract each of the lists and turn the whole thing into a nice
> straight array (it is an array of lists when unclassed). I couldn't
> get anything working with any of the apply's or ave. Any suggestions?
> This seems like it should be a common task.
I am not sure you want to your output to look like.
r[n] will give you ranks for nth person
unlist(r) vill give you one vector of ranks
If you want a table of ranks let say with names in the first row and ranks for
each
name below it it will probably need adding some NA to shorter vectors of ranks
and cbinding them together, probably using for loop.
something like
cbind(as.vector(unlist(r[1])),c(as.vector(unlist(r[2])),NA))
Not an easy task :(
Maybe sombody will come with better answer
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Cheers
Petr Pikal
petr.pikal at precheza.cz