unpivot | R Documentation |
Transforms a pivot table into a flat table (implemented by a tibble
). An
additional column with page information can be included. NA values can be
excluded from the array of values.
unpivot(pt, include_page, na_rm, keep_col_names)
## S3 method for class 'pivot_table'
unpivot(pt, include_page = TRUE, na_rm = TRUE, keep_col_names = FALSE)
pt |
A |
include_page |
A boolean, indicates whether a column with the page information is included or not. |
na_rm |
A boolean, indicates whether NA values from the array of values are removed or not. |
keep_col_names |
A boolean, if possible, keep the column names. |
A pivot table should only contain label rows and columns, and an array of values, usually numeric data.
To correctly carry out this operation, the number of rows and columns that contain labels must be defined, and the table must only contain the pivot table rows and columns.
A tibble
.
pivot_table
Other pivot table transformation functions:
extract_labels()
,
fill_labels()
,
fill_values()
,
remove_agg()
,
remove_bottom()
,
remove_cols()
,
remove_empty()
,
remove_k()
,
remove_left()
,
remove_right()
,
remove_rows()
,
remove_top()
,
replace_dec()
a_tibble <-
pt_ex |>
remove_top(1) |>
define_labels(n_col = 2, n_row = 2) |>
unpivot(include_page = FALSE)
a_tibble <-
pt_ex |>
set_page(1, 1) |>
remove_top(1) |>
define_labels(n_col = 2, n_row = 2) |>
remove_k() |>
replace_dec() |>
fill_values() |>
fill_labels() |>
remove_agg() |>
unpivot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.