Chapter 4 Methods
We describe our methods in this chapter.
문제 1
ggplot(data=mpg, mapping = aes(x=hwy, fill=drv))+
geom_histogram(alpha=0.5)+
labs(title="Histogram",
subtitle="Histogram of Highway Mile Per Gallon",
caption="Source: mpg")+
theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
문제 2
ggplot(data = mpg, mapping = aes(x=hwy, fill=drv))+
geom_histogram(alpha = 0.5)+
facet_grid(rows = vars(drv))+
labs(title = "Histogram using facet_grid()",
subtitle = "Histogram of Highway Mile Per Gallon",
caption = "Source: mpg") +
theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
문제 3
options(scipen=999)
ggplot(data=midwest, mapping = aes(x=area, y=poptotal))+
geom_point(aes(color=state, size=popdensity),alpha=0.4)+
geom_smooth(se=FALSE)+scale_x_continuous(limits=c(0,0.1))+scale_y_continuous(limits=c(0,500000))+
labs(title="Scatterplot",
subtitle="Area Vs Population",
caption="Source: midwest",
y="Population")+
theme_classic()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Warning: Removed 15 rows containing missing values (geom_point).
문제 4
ggplot(data = iris, mapping = aes(x = Sepal.Length, y = Sepal.Width, shape = Species)) +
geom_point(alpha = 0.5, size = 6, aes(color = Species)) +
labs(title = "Scatterplot",
subtitle = "Sepal.Length Vs Sepal.Width",
caption = "Source: iris") +
theme_minimal()
문제 5
ggplot(data=heightweight, mapping = aes(x=heightIn, y=weightLb, color=sex))+
geom_point(alpha=0.5, size=3)+
geom_smooth(method=lm, se=FALSE)+
labs(title ="Scatterplot",
subtitle="weight Vs Height",
caption="Source: heightweight")+
theme_classic()
## `geom_smooth()` using formula 'y ~ x'
문제 6