I have a named list whose each element is a character vector. I want to write this list into a single dataframe where I have two columns, one with the name of the character vect
A very straightforward way would be to use cbind()
, like this:
cbind(names(l),l)
This will result in the following data frame, assuming that l = list(a="ax", b="bx"):
l
a "a" "ax"
b "b" "bx"
Of course, you can rename the columns and rows by adjusting the values in colnames(l) and rownames(l). In this example, the string names are automatically also applied to the rownames of the resulting data frame, so, depending on what you'd like to do with your data,
cbind(l)
might suffice, resulting in
l
a "ax"
b "bx"
Hope I could help.