-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIMD_D2_M1_Intro_and_Packages.Rmd
97 lines (65 loc) · 2.43 KB
/
IMD_D2_M1_Intro_and_Packages.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: "Day 2 Module 1"
author: "Lauren Pandori & John Paul Schmit"
date: "1/4/21"
output: html_document
---
#### Intro and Packages {.tabset}
<details open><summary class='drop'>Data Wrangling Intro</summary>
Goals of this Day
1) Learn to load and understand how packages work
2) Understand what data wrangling is and some ways to do it.
3) Learn how to clean your import data so that R understands what it is
4) Get data in the format you need for analysis using the tidyverse.
5) Combine data from different data.frames so that it is in the correct format
<b>Disclaimer: While R provides lots of ways to check and clean up data, these tools are no replacement for sound data management that prevents data issues from happening in the first place.</b>
</details>
<br>
<details open><summary class='drop'>Working with Packages: Installing a Package</summary>
What is a package?
A package is a group of functions that someone has put together.
They come with documentation that tells you about what each function does.
First, load package
1) Go to packages tab in lower right quadrant
2) Click on "install"
3) Type name of package 'janitor'
4) Click "install"
5) Code will pop up in your console
```{r eval = FALSE, include = TRUE}
install.packages("janitor")
```
<details open><summary class='drop'> Calling a Package</summary>
To use a package, call it by using the function "library"
```{r eval = FALSE, include = TRUE}
library('janitor')
```
This is called "loading a package" or "calling a package".
</details>
<br>
<details open><summary class='drop'> Using Package</summary>
Look at the vignette
- Go to packages window of lower right quadrant
- Click on 'janitor' name in list of packages
- Vignette will show up in the 'help' tab
*take time to click a function from the vignette list*
*walk through how to get helpful info*
Did you get "error" text?
Text pops up in the console after you run code
You must decide whether it means you have to change something or not
```{r echo = TRUE, warning = TRUE, message = TRUE}
library('janitor')
```
</details>
<br>
<details open><summary class='drop'> Challenge: Install a Package</summary>
Challenge: install + call the package 'tidyverse'
</details>
<br>
<details open><summary class='drop'> Solution</summary>
Solution: install + call the package 'tidyverse'
```{r eval = FALSE, include = TRUE}
install.packages("tidyverse")
library('tidyverse')
```
</details>
<br>