合併兩個列表具有不同的結構我已經vendor_listR中
vendor_list[57:59]
[[1]]
[1] "ibm"
[[2]]
[1] "apache" "canonical" "apple" "novell"
[[3]]
[1] "gnu" "oracle"
而且我有problemtype_list
problemtype_list[57:59]
[[1]]
[1] "NVD-CWE-Other"
[[2]]
[1] "NVD-CWE-Other"
[[3]]
[1] "CWE-824"
我需要將它們結合起來,使數據幀,從而使得
A B
ibm NVD-CWE-Other
apache NVD-CWE-Other
canonical NVD-CWE-Other
apple NVD-CWE-Other
novelle NVD-CWE-Other
gnu CWE-824
oracle CWE-824
我看過類似的問題Combine two lists in a dataframe in R
但它給我的錯誤
do.call(rbind, Map(data.frame, A=problemtype_list, B=vendor_list))
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 1, 0
編輯
我的每一個列表的結構
str(vendor_list)
$ : chr "cisco"
$ : NULL
$ : chr [1:5] "redhat" "novell" "debian" "oracle" ...
$ : chr [1:4] "redhat" "novell" "debian" "google"
$ : chr [1:4] "redhat" "novell" "debian" "google"
str(problemtype_list)
$ : chr "CWE-254"
$ : chr "CWE-79"
$ : chr "NVD-CWE-Other"
$ : chr "NVD-CWE-Other"
$ : chr "CWE-254"
$ : chr "CWE-189"
$ : chr "CWE-119"
(我是對的。你有'vendor_list'空元素!) – r2evans
其實空元素不會引發錯誤。 NULL,但是,會。你可以快速地用空字符串或任何你喜歡的東西替換那些NULL。 – Troy