-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex2.3.Rmd
47 lines (32 loc) · 1.18 KB
/
ex2.3.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: "Exercises for 2.3"
output: html_notebook
---
# Q1
How would you describe the relationship between *cty* and *hwy*?
Do you have any concerns about drawing conclusions from that plot?
```{r}
library(ggplot2)
ggplot(mpg, aes(cty, hwy)) + geom_point()
```
The relationship is strong positive correlation.
# Q2
What does `ggplot(mpg, aes(model, manufacturer)) + geom_point()` show?
Is it useful? How could you modify the data to make it more informative?
```{r}
ggplot(mpg, aes(model, manufacturer)) + geom_point()
```
There's no clear pattern in above plot.
# Q3
1. `ggplot(mpg, aes(cty, hwy)) + geom_point()`: scatter plot of *cty* vs *hwy*.
1. `ggplot(diamonds, aes(carat, price)) + geom_point()`: scatter plot of *carat* vs *price*,
strong positive correlation.
1. `ggplot(economics, aes(date, unemploy)) + gemo_line()`: there's no relation between date and
unemploy rate (but there's actually).
1. `ggplot(mpg, aes(cty)) + geom_histogram()`: group all models by its *cty* value.
```{r}
ggplot(mpg, aes(cty, hwy)) + geom_point()
ggplot(diamonds, aes(carat, price)) + geom_point()
ggplot(economics, aes(date, unemploy)) + geom_line()
ggplot(mpg, aes(cty)) + geom_histogram()
```