lundi 2 mai 2016

r - Count the number of ranks in a paired sample

I'm essentially given a paired sample say:

X = c(14, 5, 2, 8 , 9, 10)

Y = c(7, 3, 4, 13, 11, 12)

If I sort and pair the two samples into say Z what function can I use to record the number of ranks in Z?

Z = c(2, 3, 4, 7, 8, 9, 10, 11, 12, 13)

so Z is now

Z = (X, Y, Y, Y, X, X, Y, Y, Y, X)

How do i count the number of X-runs which in this case is 3 of sizes 1, 2 and 1 I've tried the rle() function but I don't understand how to return the different X and Y's

Aucun commentaire:

Enregistrer un commentaire