r4ds/transform.qmd

51 lines
2.9 KiB
Plaintext
Raw Permalink Normal View History

# Transform {#sec-transform-intro .unnumbered}
2021-03-04 01:13:14 +08:00
```{r}
#| results: "asis"
#| echo: false
source("_common.R")
```
2021-03-04 01:13:14 +08:00
2022-12-05 02:05:38 +08:00
The second part of the book was a deep dive into data visualization.
2022-09-30 05:36:56 +08:00
In this part of the book, you'll learn about the most important types of variables that you'll encounter inside a data frame and learn the tools you can use to work with them.
2021-03-04 01:13:14 +08:00
2022-09-30 00:22:45 +08:00
```{r}
#| label: fig-ds-transform
#| echo: false
#| fig-cap: |
2022-09-30 00:22:45 +08:00
#| The options for data transformation depends heavily on the type of
2022-12-05 02:05:38 +08:00
#| data involved, the subject of this part of the book.
#| fig-alt: |
2022-12-05 02:05:38 +08:00
#| Our data science model, with transform highlighted in blue.
2022-09-30 00:22:45 +08:00
#| out.width: NULL
knitr::include_graphics("diagrams/data-science/transform.png", dpi = 270)
```
2021-03-04 01:13:14 +08:00
2022-09-30 05:36:56 +08:00
You can read these chapters as you need them; they're designed to be largely standalone so that they can be read out of order.
2021-03-04 01:13:14 +08:00
2022-09-30 00:22:45 +08:00
- @sec-logicals teaches you about logical vectors.
These are the simplest types of vectors, but are extremely powerful.
2022-09-30 00:22:45 +08:00
You'll learn how to create them with numeric comparisons, how to combine them with Boolean algebra, how to use them in summaries, and how to use them for condition transformations.
2022-09-30 00:22:45 +08:00
- @sec-numbers dives into tools for vectors of numbers, the powerhouse of data science.
2022-09-30 05:36:56 +08:00
You'll learn more about counting and a bunch of important transformation and summary functions.
2021-03-04 01:13:14 +08:00
2022-09-30 05:36:56 +08:00
- @sec-strings will give you the tools to work with strings: you'll slice them, you'll dice them, and you'll stick them back together again.
2023-02-27 06:38:18 +08:00
This chapter mostly focuses on the stringr package, but you'll also learn some more tidyr functions devoted to extracting data from character strings.
2022-09-30 05:36:56 +08:00
- @sec-regular-expressions introduces you to regular expressions, a powerful tool for manipulating strings.
This chapter will take you from thinking that a cat walked over your keyboard to reading and writing complex string patterns.
2021-03-04 01:13:14 +08:00
2022-09-30 05:36:56 +08:00
- @sec-factors introduces factors: the data type that R uses to store categorical data.
You use a factor when variable has a fixed set of possible values, or when you want to use a non-alphabetical ordering of a string.
2021-03-04 01:13:14 +08:00
- @sec-dates-and-times will give you the key tools for working with dates and date-times.
2022-09-30 00:22:45 +08:00
Unfortunately, the more you learn about date-times, the more complicated they seem to get, but with the help of the lubridate package, you'll learn to how to overcome the most common challenges.
2022-11-08 06:41:23 +08:00
- @sec-missing-values discusses missing values in depth.
We've discussed them a couple of times in isolation, but now it's time to discuss them holistically, helping you come to grips with the difference between implicit and explicit missing values, and how and why you might convert between them.
2022-09-30 00:22:45 +08:00
2022-09-30 05:36:56 +08:00
- @sec-joins finishes up this part of the book by giving you tools to join two (or more) data frames together.
2022-09-30 00:22:45 +08:00
Learning about joins will force you to grapple with the idea of keys, and think about how you identify each row in a dataset.