```{r echo = FALSE}
pacman::p_load(tidyverse, patchwork, knitr)
theme_book <- function() {
theme_minimal() +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(size = 16, face = "bold"),
plot.subtitle = element_text(size = 12, face = "italic"),
plot.caption = element_text(face = "italic"),
axis.title = element_text(size = 12, face = "bold"),
axis.text = element_text(size = 11),
legend.title = element_text(face = "bold"))
}
```
# What is data? {#sec-what-is-data}
*Last modified on `r format(fs::file_info("chapter-02-what-is-data.qmd")$modification_time, '%d. %B %Y at %H:%M:%S')`*
> *"The limits of my language mean the limits of my world." --- Ludwig Wittgenstein*
## General background
## Theoretical background
## R packages used
## Data
```{r}
jump_weight_tbl <- tibble(x = c(0.6, 1, 2.3, 3.5, 5.2, 7.1, 8.4, 9.2, 10),
y = 0.15*x^3 - 2.2*x^2 + 8.8*x + 3.2 + rnorm(9, 0, 0.5)) |>
mutate_all(round, 1) |>
rename(weight_mg = x, jump_length_cm = y)
```
```{r}
#| echo: false
#| message: false
#| warning: false
#| label: tbl-02-jump-weight
#| tbl-cap: "foo."
jump_weight_tbl|>
kable(align = "c", "pipe")
```
@eq-jump-weight
$$
y = 0.15\cdot x^3 - 2.2\cdot x^2 + 8.8 \cdot x + 3.2
$$ {#eq-jump-weight}
```{r}
#| message: false
#| echo: false
#| warning: false
#| fig-align: center
#| fig-height: 4
#| fig-width: 10
#| fig-cap: "foo."
#| label: fig-02-science-to-model
p1 <- ggplot(jump_weight_tbl, aes(x = weight_mg, y = jump_length_cm)) +
theme_book() +
scale_x_continuous(breaks = 0:10, limits = c(0, 10)) +
scale_y_continuous(breaks = seq(7, 21, 2), limits = c(7, 22)) +
labs(x = "Flea weight in [mg]", y = "Jump length in [cm]",
title = "Science") +
theme(axis.text = element_blank())
p2 <- ggplot(jump_weight_tbl, aes(x = weight_mg, y = jump_length_cm)) +
theme_book() +
geom_point() +
scale_x_continuous(breaks = 0:10, limits = c(0, 10)) +
scale_y_continuous(breaks = seq(7, 21, 2), limits = c(7, 22)) +
labs(x = "weight_mg", y = "jump_length_cm",
title = "Data")
p3 <- ggplot(jump_weight_tbl, aes(x = weight_mg, y = jump_length_cm)) +
theme_book() +
geom_function(fun = \(x) 0.15*x^3 - 2.2*x^2 + 8.8*x + 3.2,
size = 1) +
scale_x_continuous(breaks = 0:10, limits = c(0, 10)) +
scale_y_continuous(breaks = seq(7, 21, 2), limits = c(7, 22)) +
labs(x = "Influencer (X)", y = "Outcome (Y)",
title = "Model") +
theme(axis.text = element_blank())
p1 + p2 + p3 +
plot_layout(ncol = 3) +
plot_annotation(tag_levels = 'A', tag_prefix = '(', tag_suffix = ')') &
theme(plot.tag = element_text(size = 16, face = "bold"))
```
```{r}
#| message: false
#| echo: false
#| warning: false
#| fig-align: center
#| fig-height: 4.5
#| fig-width: 5.5
#| fig-cap: "foo."
#| label: fig-02-science-with-model
ggplot(jump_weight_tbl, aes(x = weight_mg, y = jump_length_cm)) +
theme_book() +
geom_point(size = 3, shape = 21, fill = "gray75") +
geom_function(fun = \(x) 0.15*x^3 - 2.2*x^2 + 8.8*x + 3.2) +
scale_x_continuous(breaks = 0:10, limits = c(0, 10)) +
scale_y_continuous(breaks = seq(7, 21, 2), limits = c(7, 22)) +
labs(x = "Flea weight in [mg]", y = "Jump length in [cm]",
title = "Science with data and model")
```
## Alternatives
Further tutorials and R packages on XXX
## Glossary
term
: what does it mean.
## The meaning of "Data Science" in this chapter.
- itemize with max. 5-6 words
## Summary
## References {.unnumbered}