Ff Yy Ff Yy - 1 year ago 93
R Question

Subsetting a vector using multiple conditions

> which(LETTERS=="A")
[1] 1
> which(LETTERS=="B")
[1] 2

Can i use one statement in which to get the value of 1,2?

which(LETTERS=="B" or "A")
Error: unexpected symbol in "which(LETTERS=="B" or"

Answer Source
which(LETTERS == "A" | LETTERS == "B")


which(LETTERS %in% c("A", "B"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download