I have a dataframe “df”. I want to create two subsets (a & b) from a conditional statement, say, variable “x” having value greater than 10. In SAS, this would be something like:
data a, b; set df; if x>10 then output a; else output b.
Is there a way to do this in R?
I have a dataframe df. I want to create two subsets (a & b)
Share
You could use
split:The second argument of split takes a factor, so you can use more complex statements to give more splits.