Say I have d<-c(1,2,3,4,5,6,6,7)
. How can I select the indices from d that meet a certain condition such as x>3
and x<=6
(i.e. d[4], d[5], d[6], d[7])?
Use which
> which(d>3 & d<=6)
[1] 4 5 6 7
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