I'm trying to create a boxplot of the variable 'duration in seconds' over the categories 'age' from the dataset 'trips', but only including values of 'hours' less than 1 hour.
To create the boxplot:
boxplot(duration ~ agecat, data = trips)
However, how to only include hours < 1 hour??
?? [trips$hours < 1] ??
boxplot(trips$duration[trips$hours < 1] ~ trips$agecat)
gives the error
Error in stats::model.frame.default(formula = trips$duration[trips$hours < :
variable lengths differ (found for 'trips$agecat')
boxplot(duration ~ agecat, data = trips[hours < 1])
gives the error
Error in `[.data.frame`(trips, hours < 1) : object 'hours' not found
boxplot(duration ~ agecat, data = trips[trips$hours < 1])
gives the error
Error in [.data.frame
(trips, trips$hours < 1) :
undefined columns selected
Help is much appreciated!!