你好简单的R问题,但是List_A
中每个项目在数据框架中重复一次List_B
中每个项目的最佳方法是什么。
List_A = c("a","b","c")
List_B = c("one","oneb","two","twoa","three","threea")
期望的输出:
data.frame(List_A = c("a","a","a","a","a","a","b","b","b","b","b","b","c","c","c",,"c","c","c"),
List_B = c("one","oneb","two","twob","three","threeb","one","oneb","two","twob","three","threeb","one","oneb","two","twob","three","threeb"))
答案 0 :(得分:2)
按照@HubertL建议后,我能够获得重复List_B
的数据框。
expand.grid(List_A=List_A, List_B=List_B)