I am trying to compute the median vector of a data set s
with column A1
and B1
. The median vector is the median for each observation from both columns.
I tried to do this and it did not work.
median(s[c("A1","B1")])
Is there another way to do it?
The median of two observations is simply the mean. So rowMeans(s[,c("A1","B1")])
. Equivalently, apply(s[,c("A1","B1")],1,median)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With