Problem
This question is an extension on the topic of subsetting using multiple logical conditions—particularly strict inequalities—to subset a data frame in R (see here and here).
Say my variable ranges from 0 to 100. I need to create a subset that returns values that are between 50 and 100, but also values less than 25.
# Data
df$var = seq(1:100)
# Desired Subset
df$var[df$var > 50 & df$var < 100 & df$var < 25]
Question
- What is the best way to make a subset involving multiple inequalities using base R?
- Are solutions using non-base R packages more elegant?