pivot_longer | R Documentation |
pivot_longer()
"lengthens" data, increasing the number of rows and decreasing the number of columns. The inverse
transformation is pivot_wider()
.
pivot_longer(
data,
cols,
names_to = "name",
names_prefix = NULL,
names_sep = NULL,
names_pattern = NULL,
values_to = "value",
values_drop_na = FALSE,
...
)
data |
|
cols |
< |
names_to |
|
names_prefix |
|
names_sep, names_pattern |
|
values_to |
|
values_drop_na |
|
... |
Additional arguments passed on to methods. |
A data.frame
.
wide_data <- data.frame(replicate(5, rnorm(10)))
# Customizing the names
pivot_longer(
data = wide_data,
cols = c(1, 2),
names_to = "Column",
values_to = "Numbers"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.