I have a table input of data on cars. Roughly 73 observations with 11 variables. I was tasked to find the mean of MPG by gear_ratio. This is the output I receive after completing an aggregate function.
dfdata=data.frame(cars10)
aggregate(x= dfdata$mpg, by=list(dfdata$gear_ratio), FUN=mean)
Gear_ratio | Mean_MPG |
---|---|
2.19 | 14 |
2.24 | 21 |
2.2.26 | 25 |
2.28 | 17 |
2.2.47 | 21 |
2.53 | 17 |
2.56 | 17.5 |
2.73 | 21.3 |
2.75 | 20.12 |
2.87 | 34 |
3.05 | 23.6 |
3.15 | 17 |
3.5 | 23 |
3.87 | 18 |
3.9 | 30.3 |
Next I would like to group and graph the following means by a range of Gear_ratio. The ranges need to be a) 2.0-2.5 b) 2.5 to 3.0 c)3.0-3.5 and d)3.5-4.0. I'd like to change colors for each group as well.
*Wasn't sure if there was a way to group by range in the initial aggregate function I created to find the mean in the first place.