I have two types of data.
type_1 <- list(
"One" = "Something",
"Two" = "Something Else"
)
type_2 <- list(
"One" = c(1,2,3),
"Two" = c(4,5,6)
)
For both types I would like to create dataframes where the left hand side, or listnames (One & Two
) are column_one
, and where the right hand side are column_two
.
I tried a few of these approaches without much success.
What is the correct way to do this?
Desired output:
type_1 <- structure(
list(column__one = list("One","Two"), column_two = list("Something", "Something Else")),
row.names = c("A", "B"), class = "data.frame")
column__one column_two
A One Something
B Two Something Else
type_2 <- structure(
list(column__one = list("One","Two"), column_two = list(a= c(1,2,3), b=c(4,5,6))),
row.names = c("A", "B"), class = "data.frame")
column__one column_two
A One 1, 2, 3
B Two 4, 5, 6