I have a dataframe obs with 145 rowns and more than 1000 columns.
For each row I would like to extract the value of the 95th percentile but calculated only on the data greater or equal to 1.
I managed calculating a value for each row, considering all data, as follows:
p95.obs <- apply(obs,1,quantile,probs=c(.95))
To include the greater than option I tried
p95.obs <- apply(obs>=1,1,quantile,probs=c(.95))
but in this way I obtained only 1 for each row.
You can try
apply(obs, 1, function(x) quantile(x[x>=1], probs=.95))
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