3
我有R中的列表,其中每個元素具有可變數量的字符串,例如:轉換可變長度列表分成邊列表的igraphř
el: list
chr [1:3] "sales", "environment", "communication"
chr [1:2] "interpersonal", "microsoft office"
chr [1:4] "writing", "reading", "excel", "python"
欲該列表轉換成2列的矩陣,該矩陣如果兩個字符串出現在列表中的相同元素中,則並排放置兩個字符串,例如
matrix:
"sales", "environment"
"sales, "communication"
"environment", "communication"
"interpersonal", "microsoft office"
"writing", "reading"
"writing", "excel"
"writing", "python"
"reading", "excel"
"reading", "python"
"excel", "python"
我該如何解決這個問題?
很好的答案。可能稍微快一點,將'unlist'並且輸入矩陣 - '矩陣(unlist(lapply(el,combn,2)),ncol = 2,byrow = TRUE) - 雖然沒有測試過.. – thelatemail
@thelatemail謝謝,我沒有正確檢查。 – akrun