| extract_labels | R Documentation |
Extract the given set of labels from a table column in compact format to generate a new column in the table.
extract_labels(pt, col, labels)
## S3 method for class 'pivot_table'
extract_labels(pt, col = 1, labels = c())
pt |
A |
col |
A number, column from which labels are extracted. |
labels |
A vector of strings, set of labels to extract. |
Sometimes a table column includes values of multiple label fields, this is generally known as compact table format. Given a column number and a set of labels, it generates a new column with the labels located at the positions they occupied in the original column and removes them from it.
A pivot_table object.
pivot_table
Other pivot table transformation functions:
fill_labels(),
fill_values(),
remove_agg(),
remove_bottom(),
remove_cols(),
remove_empty(),
remove_k(),
remove_left(),
remove_right(),
remove_rows(),
remove_top(),
replace_dec(),
unpivot()
pt <- pivot_table(df_ex_compact) |>
extract_labels(col = 1, labels = c("b1", "b2", "b3", "b4", "Total general"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.