So I have a list with me as below, what I want is to split them into three separate dataframes (with names as Banana/Strawberry & apple) as shown in expected output. I have already seen this (Splitting List into dataframe R) but its exact opposite of what I want. I dont want to combine then I want to split them into three dataframe with same name as list header.
list_a <- list(`Banana` = c(8.7), `Strawberry` = c(2.3), `Apple` = c(3.5))
DF1
Banana
8.7
DF2
Strawberry
2.3
DF3
Apple
3.5
Any Solution preferably in Tidyverse would be greatly appreciated. Actual problem has lot more columns in the list.
First convert them all to a tibble:
list_a <- list(`Banana` = c(8.7), `Strawberry` = c(2.3), `Apple` = c(3.5))
list_a <- purrr::map(list_a, tibble::as_tibble)
Then send this to the global environment:
list2env(list_a, envir = .GlobalEnv)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With