I have thousands of dataset like this:
>student1
quantities score
[1] 4 10
[2] 1 12
[3] 78 5
[4] 6 294
I'd like to calculate the median of scores for this student. For every score, we have some quantities. In this case, I want it to return 5 since the median is one of the 78 5s.
I've looked at some posts here like how to calculate the median on grouped dataset? , but I can't use that because I have thousands of dataset.
I've also tried to install aroma.light package and matrixstats package but still, I can't use the "weighted.median function" thing. It tells me
Error: could not find function "weightedMedians"
ok, above is just an example, my real dataset is like:
>test
[,1] [,2]
info 3 10
info 2 20
4 86779637
1 135777
7 2342
but when I tried to use
>rep(test[, 1], test[, 2])
it appears
Error in rep(test[, 1], test[, 2]) : invalid 'times' argument
In addition: Warning message:
NAs introduced by coercion
what can I do now?