标签: r paste
这是我的示例代码尝试
paste(1:2,"x",0:1)
这是输出
[1] "1x0" "2x1"
但这是我期望的输出:
[1] "1x0" "1x1" "2x0" "2x1"
答案 0 :(得分:1)
使用expand.grid
expand.grid
apply(expand.grid(1:2,"x",0:1),1,paste,collapse="") [1] "1x0" "2x0" "1x1" "2x1"