Suppose I have a vector
A=[1,3, 4, 5]
logical = [TRUE, TRUE, FALSE, FALSE]
How do I index TRUE elements so that it returns 1 and 3?
In matlab you can do things like A(logical)
or A(~logical)
What is equivalent syntax for R?
A[logical]
does the trick.
This is in Introduction to R.
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