KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If I want to select a subset of data in R, I can use the subset function. I wanted to base an analysis on data that that was matching one of a few criteria, e.g. that a certain variable was either 1, 2 or 3. I tried myNewDataFrame <- subset(bigfive, subset = (bigfive$bf11==(1||2||3))) It did always just select values that matched the first of the criteria, here 1. My assumption was that it would start with 1 and if it does evaluate to "false" it would go on to 2 and than to 3, and if none matches the statement after == is "false" and if one of them matches, it is "true". I got the right result using newDataFrame <- subset(bigfive, subset = (bigfive$bf11==c(1,2,3))) But I would like to be able to select data via logical operators, so: why did the first approach not work?
Tags (comma-separated)
Save Edits
Cancel