Reputation: 123
[[29]]
type lineNum cat sel
"I" "25" "DOR" "MN-A"
act desc descChanged calc
"+" "Door labor minimum" "1" "1"
qty unit coverageName replace
"1" "EA" "Dwelling" "58.58"
total acv recoverable acvTotal
"58.58" "58.58" "1" "58.58"
rcvTotal isPartOfInitSettle laborTotal laborBase
"58.58" "0" "58.58" "58.58"
[[30]]
type lineNum cat sel
"I" "26" "WDW" "MN-A"
act desc descChanged calc
"+" "Window labor minimum" "1" "1"
qty unit coverageName replace
"1" "EA" "Dwelling" "69.5"
total acv recoverable acvTotal
"69.5" "69.5" "1" "69.5"
rcvTotal isPartOfInitSettle laborBase
"69.5" "0" "69.5"
Here is a sample of my data.The number of columns are not the same. I am trying to create a data frame from this. I essentially want two rows here and match up by the column name.
I tried using plyr but it doesn't work as the number of columns is not the same.
Any suggestion?
Upvotes: 1
Views: 33
Reputation: 887951
We could use map
from purrr
library(dplyr)
library(purrr)
map_df(lst, as.list)
# A tibble: 3 x 5
# A B C D E
# <int> <int> <int> <int> <int>
#1 1 2 3 NA NA
#2 1 2 NA NA NA
#3 1 2 3 4 5
lst <- list(setNames(1:3, LETTERS[1:3]), setNames(1:2, LETTERS[1:2]),
setNames(1:5, LETTERS[1:5]))
Upvotes: 3