multi_id_pivot_wider | R Documentation |
Transforming data.frame with Multiple Identifying columns into Wide Format
multi_id_pivot_wider(
data,
id,
param_from,
value_from,
drop_na = FALSE,
drop_lvl = FALSE
)
data |
( |
id |
( |
param_from |
( |
value_from |
( |
drop_na |
( |
drop_lvl |
( |
This function allows to identify observations on the basis of several columns. Warning: Instead of nesting duplicated values, the function will throw an error if the same parameter is provided twice for the same observation.
data.frame
in a wide format.
test_data <- data.frame(
the_obs = c("A", "A", "A", "B", "B", "B", "C", "D"),
the_obs2 = c("Ax", "Ax", "Ax", "Bx", "Bx", "Bx", "Cx", "Dx"),
the_param = c("weight", "height", "gender", "weight", "gender", "height", "height", "other"),
the_val = c(65, 165, "M", 66, "F", 166, 155, TRUE)
)
multi_id_pivot_wider(test_data, c("the_obs", "the_obs2"), "the_param", "the_val")
multi_id_pivot_wider(test_data, "the_obs2", "the_param", "the_val")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.