How to cross-paste all combinations of two vectors (each-to-each)?

后端 未结 4 1416
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 06:04

I need to paste all combinations of elements from two character vectors, \"each\" to \"each\": instead of

> paste0(c(\"a\", \"b\"), c(\"c\", \"d\"))
[1]          


        
4条回答
  •  青春惊慌失措
    2020-12-09 06:26

    Another (less generally useful) incantation:

    levels(interaction(x,y,sep=""))
    # [1] "ac" "bc" "ad" "bd"
    

提交回复
热议问题