R: 'Multiply' dataframe columns of strings

后端 未结 2 1502
礼貌的吻别
礼貌的吻别 2021-01-23 01:44

Not sure what this operation is called, and Google did not help.

Say I have two simple dataframes like this:

df1 <- data.frame(factor1 = c(\"a\", \"b         


        
2条回答
  •  野性不改
    2021-01-23 02:11

    Here is another option with expand.grid

    Map(expand.grid, factor1 = df1, factor2 = df2)$factor
    #    factor1 factor2
    #1       a       x
    #2       b       x
    #3       c       x
    #4       a       y
    #5       b       y
    #6       c       y
    #7       a       z
    #8       b       z
    #9       c       z
    

提交回复
热议问题