rm(list=ls())
library(tidyverse)
Rysunki w oparciu o kody z książki R for Data Science.
mpg
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = cty))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = year))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = as.character(year)))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = as.factor(year)))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = year, color = class))
# Left
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, alpha = class))
# Right
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, shape = class))
# Left
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, alpha = year))
# Right
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, shape = class, color = class, size = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_wrap(~ class, nrow = 3)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_wrap(~ class, ncol = 2)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_wrap(~ year, nrow = 2)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
facet_grid(drv ~ cyl)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class, shape = fl)) +
facet_grid(drv ~ cyl)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class), position = "jitter")
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class), position = "jitter") +
facet_grid(drv ~ cyl)
summary(mpg)
manufacturer model displ year cyl
Length:234 Length:234 Min. :1.600 Min. :1999 Min. :4.000
Class :character Class :character 1st Qu.:2.400 1st Qu.:1999 1st Qu.:4.000
Mode :character Mode :character Median :3.300 Median :2004 Median :6.000
Mean :3.472 Mean :2004 Mean :5.889
3rd Qu.:4.600 3rd Qu.:2008 3rd Qu.:8.000
Max. :7.000 Max. :2008 Max. :8.000
trans drv cty hwy fl
Length:234 Length:234 Min. : 9.00 Min. :12.00 Length:234
Class :character Class :character 1st Qu.:14.00 1st Qu.:18.00 Class :character
Mode :character Mode :character Median :17.00 Median :24.00 Mode :character
Mean :16.86 Mean :23.44
3rd Qu.:19.00 3rd Qu.:27.00
Max. :35.00 Max. :44.00
class
Length:234
Class :character
Mode :character
mpg$year %>% as.factor %>% summary
1999 2008
117 117
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(drv ~ cyl)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
facet_grid(drv ~ cyl)
Wykonać 10 wykresóW analogicznych jak na ćwiczeniach z wykorzystaniem danych z plik acsNew.csv ze strony Jareda P. Landera