Hello Rstudio community,
I have Data that reach from age 18-70. Now i want to subset it into groups that reach from 20-25, 25-30 and so on.
I tried:
Data20 <- subset(Data, Age <=18 & !>25 )
Data25 <-subset(Data,Age <=25 & !>30)
which creates the error unexpected token.
To get rows where age is 20 - 25, inclusive, you would write
Data25 <-subset(Data,Age >= 20 & Age <= 25)
You might find the cut() function useful since you can set multiple break points and label all of the groups at once. The groups would remain in one data frame, which may or may not meet your needs.