r4ds/explore.Rmd

37 lines
1.9 KiB
Plaintext
Raw Normal View History

2016-04-27 15:04:29 +08:00
# (PART) Explore {-}
2016-04-21 21:01:34 +08:00
# Introduction
2016-02-12 06:31:34 +08:00
2016-07-12 04:48:58 +08:00
```{r setup, include = FALSE}
2016-05-19 00:57:20 +08:00
library(ggplot2)
library(dplyr)
```
2016-07-12 04:48:58 +08:00
If you are like most humans, your brain is not designed to work with raw data. Your working memory can only pay attention to a few values at a time, which makes it difficult to discover patterns in raw data. For example, can you spot the striking relationship between $X$ and $Y$ in the table below?
2016-05-19 00:57:20 +08:00
```{r data, echo=FALSE}
2016-07-12 04:48:58 +08:00
circle <- tibble(
pi = sort(rep(seq(0.2, 1.8 * pi, length = 5), 2) + runif(10, -0.15, 0.15)),
x = cos(pi) + 1,
y = sin(pi) - 1
)
circle %>%
select(-pi) %>%
knitr::kable(digits = 2)
2016-05-19 00:57:20 +08:00
```
2016-07-12 04:48:58 +08:00
While we may stumble over raw data, we can easily process visual information. Within your mind is a powerful visual processing system fine-tuned by millions of years of evolution. As a result, often the quickest way to understand your data is to visualize it. Once you plot your data, you can instantly see the relationships between values. Here, we see that the values fall on a circle.
2016-05-19 00:57:20 +08:00
2016-07-18 22:52:55 +08:00
```{r echo=FALSE, dependson = data, fig.asp = 1, out.width = "30%", fig.width = 3}
2016-07-12 04:48:58 +08:00
ggplot(circle, aes(x, y)) +
geom_point() +
coord_fixed()
2016-05-19 00:57:20 +08:00
```
2016-05-20 05:06:22 +08:00
Visualization works because your brain processes visual information in a different (and much wider) channel than it processes symbolic information, like words and numbers. However, visualization is not the only way to comprehend data.
2016-05-19 00:57:20 +08:00
2016-05-20 05:06:22 +08:00
You can also comprehend data by transforming it. You can easily attend to a small set of summary values, which lets you absorb important information about the data. This is why it feels natural to work with things like averages, maximums, minimums, medians, and so on.
2016-05-19 00:57:20 +08:00
2016-07-12 04:48:58 +08:00
Together, visualisation and transformation form a powerful set of tools known as exploratory data analysis, or EDA for short. In this part of the book, you'll learn R through EDA, mastering the minimal set of skills to start gaining insight from your data.