I have a data frame "a" and it has a variable called "VAL". I want to count the elements where the VAL value is 23 or 24.
I used two codes that worked fine:
nrow(subset(a,VAL==23|VAL==24) nrow(subset(a,VAL %in% c(23,24)))
But I tried another code that gives unexpected output, and I don't know why.
nrow(subset(a,VAL ==c(23,24)))
Even if I change the order of 23 and 24, it gives another unexpected conclusion.
nrow(subset(a,VAL ==c(24,23)))
Why are these codes incorrect? What are they actually doing?
r subset
Creamstat
source share