It's fairly straightforward with help from the purrr package:
library(purrr)
map_df(OB1, function(x) {
if (length(x) == 0) {
data.frame(id=NA_character_, nam=NA_character_, stringsAsFactors=FALSE)
} else {
data.frame(id=x[1], nam=names(x), stringsAsFactors=FALSE)
}
}, .id="V1")
O
Hi,
I have a list like below.
OB1 <- structure(list(aa0 = NULL,
aa1 = structure("23403", .Names = "BB10"),
aa2 = structure("54904", .Names = "BB20"),
aa3 = structure("22897", .Names = "BB30"),
aa4 = structure("3751", .Names = "BB40"),
aa5 = NULL,
aa6 = structure("3679", .Names = "BB50"),
2 matches
Mail list logo