forked from tidyverse/datascience-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarwars.Rmd
72 lines (49 loc) · 2.1 KB
/
starwars.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: "Visualizing Starwars characters"
author: "Mine Çetinkaya-Rundel"
output: github_document
---
```{r load-packages, include=FALSE}
library(tidyverse)
```
### Glimpse at the starwars data frame.
```{r glimpse-starwars}
glimpse(starwars)
```
### Modify the following plot to change the color of all points to `"pink"`.
```{r scatterplot}
ggplot(starwars,
aes(x = height, y = mass, color = gender, size = birth_year)) +
geom_point(color = "#30509C")
```
### Add labels for title, x and y axes, and size of points. Uncomment to see the effect.
```{r scatterplot-labels}
ggplot(starwars,
aes(x = height, y = mass, color = gender, size = birth_year)) +
geom_point(color = "#30509C") +
labs(
#title = "___",
#x = "___",
#y = "___",
#___
)
```
### Pick a single categorical variable from the data set and make a bar plot of its distribution.
(A little bit of starter code is provided below, and the code chunk is set to not be evaluated with `eval = FALSE` because the current code in there is not valid code and hence the document wouldn't knit. Once you replace the code with valid code, set the chunk option to `eval = TRUE`, or remove the `eval` option altogether since it's set to `TRUE` by default.)
```{r barplot, eval = FALSE}
ggplot(starwars, aes(___)) +
geom___
```
### Pick a single numerical variable and make a histogram of it.
(This time no starter code is provided, you're on your own!)
```{r histogram}
```
### Pick a numerical variable and a categorical variable and make a visualisation (you pick the type!) to visualise the relationship between the two variables. Along with your code and output, provide an interpretation of the visualisation.
```{r num-cat}
```
### Pick two categorical variables and make a visualisation to visualise the relationship between the two variables. Along with your code and output, provide an interpretation of the visualisation.
```{r cat-cat}
```
### Pick two numerical variables and two categorical variables and make a visualisation that incorportes all of them and provide an interpretation with your answer.
```{r multi}
```