What is the best way to transpose a data.frame in R and to set one of the columns to be the header for the new transposed table? I have coded up a way to do this below. As I am
Here are my two cents using dplyr for a data.frame that has grouping columns and an id column.
dplyr
data.frame
id
id_transpose <- function(df, id){ df %>% ungroup() %>% select(where(is.numeric)) %>% t() %>% as_tibble() %>% setNames(., df %>% pull({{id}})) }