Skip to content

Commit 97fab61

Browse files
committed
Tidyverse TOC and spell check
1 parent 7160923 commit 97fab61

File tree

3 files changed

+442
-427
lines changed

3 files changed

+442
-427
lines changed

1-Tidyverse.Rmd

+27-12
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@ library(lubridate)
1515
examples <- readLines('Examples.R')
1616
```
1717

18+
# Table of Contents
1819

19-
# Tibbles
20+
1. [Tibbles](#tibbles)
21+
22+
1.1 [Why tibbles?](#why)
23+
24+
1.2 [Working with tibbles](#working)
25+
26+
1.3 [Examples and exercises](#eeTibbles)
27+
28+
2. [Importing Data](#import)
29+
30+
2.1 [Comments and metadata](#skip)
31+
32+
2.2 [Examples and exercises](#eeImport)
33+
34+
# <a name="tibbles"></a>Tibbles
2035

2136
In the tidyverse the commonly returning objects are not data.frame but tibbles, which can be created with either the `tibble()` or `data_frame()` functions.
2237

2338
What is tibble?
2439

25-
- modern way of loooking at the traditional data.frame
40+
- modern way of looking at the traditional data.frame
2641
- you will get a lot more useful information than the data.frames
2742
- tibble is part of tibble package and part of the core tidyverse package
2843

@@ -46,9 +61,9 @@ as_tibble(df)
4661
```
4762

4863

49-
## Why Tibbles?
64+
## <a name="why"></a>Why Tibbles?
5065

51-
- `tibble()` doesnt change the inputs (i.e. it doesn't convert strings to factors).
66+
- `tibble()` doesn't change the inputs (i.e. it doesn't convert strings to factors).
5267

5368
```{r}
5469
data.frame(x = letters[1:5]) %>%
@@ -95,7 +110,7 @@ as.data.frame(who) # try printing as a data.frame (output not shown here)
95110

96111
Why not use a tibble? There are a few packages that don't get along with tibbles (e.g. the missForest package). In this case, you may need to convert your tibble into a data.frame using `as.data.frame()`.
97112

98-
## Working with tibbles
113+
## <a name="working"></a>Working with tibbles
99114

100115
Here is a more complicated tibble, consisting of a random start time within +/- 12 hours of now and a random end time within the next 30 days (where "now" is relative to when this code is run).
101116

@@ -179,13 +194,13 @@ options(tmp)
179194

180195
You can also use the `tibble.width = Inf` option to print all columns. There are more options documented at `package?tibble`.
181196

182-
## Examples and Exercises
197+
## <a name="eeTibbles"></a>Examples and Exercises
183198

184199
For more examples, see line ```r which(examples == "########## tibble Examples ##########")```of [Examples.R](https://github.com/ravichas/TidyingData/blob/master/Examples.R).
185200

186201
Practice exercises for this section can be found in [Exercsies.Rmd](https://github.com/ravichas/TidyingData/blob/master/Exercises.md#tibbleEx).
187202

188-
# Importing Data
203+
# <a name="import"></a>Importing Data
189204

190205
RStudio has a nice data import utility under File > Import Dataset. This will generate the code to repeat the import (i.e. so you can save it to your script).
191206

@@ -196,8 +211,8 @@ If you are comfortable with writing the code directly, the following functions w
196211
- `?read_csv`: import comma separated values data
197212
- `?read_csv2`: import semicolon separated values data (European version of a csv)
198213
- `?read_tsv`: import tab delimited data
199-
- `?read_delim`: import a text file with data (e.g. space delimted)
200-
- `?read_excel`: import Excel formated data (either xls or xlsx format)
214+
- `?read_delim`: import a text file with data (e.g. space delimited)
215+
- `?read_excel`: import Excel formatted data (either xls or xlsx format)
201216

202217
If you are familiar with R you may recognize that there are data.frame generating counterparts from the utils package (e.g. `read.csv()` and `read.delim()`). Why would we want to use these function from the readr package over the base-R functions?
203218

@@ -215,9 +230,9 @@ require(readr)
215230
read_csv('Data/WHO-2a.csv')
216231
```
217232

218-
## Comments/Metadata
233+
## <a name="skip"></a>Comments/Metadata
219234

220-
Sometimes, there will be extra metadata at the top of a file, often preceded with '#'. How do we read a dataset that has some metadata (indicated by '#')? What if the extra lines aren't properly marked with '#'?
235+
Sometimes, there will be extra metadata at the top of a file, often preceded with '#'. How do we read a data set that has some metadata (indicated by '#')? What if the extra lines aren't properly marked with '#'?
221236

222237
```{r}
223238
# we want to skip this first line
@@ -230,6 +245,6 @@ read_csv("Data/WHO-2.csv", comment = "#")
230245
read_csv("Data/WHO-2.csv", skip = 1)
231246
```
232247

233-
# Exercises
248+
## <a name="eeImport"></a>Exercises
234249

235250
Work through the exercises in the Tidyverse section of [Exercises.R](https://raw.githubusercontent.com/ravichas/TidyingData/master/Exercises.R).

0 commit comments

Comments
 (0)