forked from mccallpitcher/LearnR-Part1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_inclass_exercises.qmd
More file actions
79 lines (42 loc) · 1.69 KB
/
01_inclass_exercises.qmd
File metadata and controls
79 lines (42 loc) · 1.69 KB
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
73
74
75
76
77
78
79
---
title: "Learn R Part I In-class Exercises"
format: html
editor: visual
---
Welcome to your first Quarto document! This is where you will try out all of the hands-on exercises in the workshop.
## 05. How do I write and run code in a coding notebook?
Write and run code that finds the square root of 60
Hint: the square root function in R is `sqrt()`
```{r}
```
## 06. What is an object and how do I create one?
Create an object called `my_age` that stores your age, then call the object so it prints to the Console.
```{r}
```
## 08. **How do I import data?**
Load the Taylor Swift data using `read_csv()`. You can name your data frame object `tswift`
```{r}
```
## 09. **How can I get to know my variables?**
Using `summary()`, determine whether the mean or median of `danceability` is greater.
```{r}
```
## 10. **What are some ways I can transform my data?**
### 10.1 Subset rows with `filter()`
Filter `tswift` to only contain songs that are *NOT* on the "Lover" album
```{r}
```
### 10.2 Subset columns with `select()`
Limit the columns in `tswift` to only include `name` and `speechiness`
```{r}
```
### 10.3 Sort rows with `arrange()`
Find the 3 most popular Taylor Swift songs (according to Spotify)
*Hint:* Browse the environment pane for the variable that measures this (it's near the bottom)
```{r}
```
### 10.4 Create new variables with `mutate()`
Create a new variable in `tswift` that multiplies `danceability` by 100 (you pick the name of the new variable), then limit your columns to `name`, `danceability`, and your new variable.
Note: The symbol for multiplication in R is `*`
```{r}
```