## Load datasets package
library(datasets)
## Load airquality data
data(airquality)
## Show first 15 rows
head(airquality, 15)
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6
7 23 299 8.6 65 5 7
8 19 99 13.8 59 5 8
9 8 19 20.1 61 5 9
10 NA 194 8.6 69 5 10
11 7 NA 6.9 74 5 11
12 16 256 9.7 69 5 12
13 11 290 9.2 66 5 13
14 14 274 10.9 68 5 14
15 18 65 13.2 58 5 15
## ‘Ozone’ numeric Ozone (ppb)
## ‘Solar.R’ numeric Solar R (lang)
## ‘Wind’ numeric Wind (mph)
## ‘Temp’ numeric Temperature (degrees F)
## ‘Month’ numeric Month (1-12)
## ‘Day’ numeric Day of month (1-31)
library(ggplot2)
ggplot(airquality, aes(x = Temp, y = Ozone, color = Solar.R, group = Month)) +
geom_point() +
geom_smooth() +
facet_wrap( ~ Month, ncol = 1) +
labs(title = "Ozone concentration grouped by Month") +
theme_bw()
## stat_smooth
## method: smoothing method (function) to use, eg. lm, glm, gam, loess,
## rlm. For datasets with n < 1000 default is ‘loess’. For
## datasets with 1000 or more observations defaults to gam, see
## ‘gam’ for more details.