Generate combination of data frame and vector

后端 未结 3 553
一整个雨季
一整个雨季 2021-01-18 08:46

I know expand.grid is to create all combinations of given vectors. But is there a way to generate all combinations of a data frame and a vector by taking each r

3条回答
  •  终归单人心
    2021-01-18 09:43

    As for me the simplest way is merge(df, as.data.frame(c))

      a b  c
    1 1 5  9
    2 2 6  9
    3 3 7  9
    4 1 5 10
    5 2 6 10
    6 3 7 10
    

提交回复
热议问题