Updates for tidy data
This commit is contained in:
parent
3411382803
commit
0b5782dd45
|
@ -325,7 +325,7 @@ An alternative to `names_sep` is `names_pattern`, which you can use to extract v
|
||||||
### Data and variable names in the column headers
|
### Data and variable names in the column headers
|
||||||
|
|
||||||
The next step up in complexity is when the column names include a mix of variable values and variable names.
|
The next step up in complexity is when the column names include a mix of variable values and variable names.
|
||||||
For example, take the `family` dataset:
|
For example, take the `household` dataset:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
family
|
family
|
||||||
|
@ -338,7 +338,7 @@ We again we need to supply a vector to `names_to` but this time we use the speci
|
||||||
[^data-tidy-1]: Calling this `.value` instead of `.variable` seems confusing so I think we'll change it: <https://github.com/tidyverse/tidyr/issues/1326>
|
[^data-tidy-1]: Calling this `.value` instead of `.variable` seems confusing so I think we'll change it: <https://github.com/tidyverse/tidyr/issues/1326>
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
family |>
|
household |>
|
||||||
pivot_longer(
|
pivot_longer(
|
||||||
cols = !family,
|
cols = !family,
|
||||||
names_to = c(".value", "child"),
|
names_to = c(".value", "child"),
|
||||||
|
@ -530,10 +530,6 @@ country_tb |>
|
||||||
ggplot(aes(year, log10(count), group = country)) +
|
ggplot(aes(year, log10(count), group = country)) +
|
||||||
geom_line()
|
geom_line()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
country
|
|
||||||
|
|
||||||
library(gapminder)
|
library(gapminder)
|
||||||
gapminder |>
|
gapminder |>
|
||||||
pivot_wider(
|
pivot_wider(
|
||||||
|
|
Loading…
Reference in New Issue