An option is to stack into a two column data.frame, and spread it back to 'wide' format
library(tidyverse) enframe(df) %>% unnest(value) %>% group_by(name) %>% mutate(rn = row_number()) %>% spread(name, value) %>% select(-rn) # A tibble: 4 x 2 # name value # <dbl> <dbl> #1 11 -0.484 #2 12 -0.110 #3 13 -0.328 #4 14 0.0737
Or another option is to make use of pivot_longer from the devel version of tidyr
df %>% set_names(str_c(names(.), "_", cumsum(names(.) == "name"))) %>% as_tibble %>% mutate(rn = row_number()) %>% pivot_longer(-rn, names_to =c(".value", "group"), names_sep = '_') %>% select(name, value)
Or using base R
reshape(transform(stack(df), rn = ave(seq_along(ind), ind, FUN = seq_along)), idvar = 'rn', direction = 'wide', timevar = 'ind')