Perform 'cross product' of two vectors, but with addition

前端 未结 2 1320
北恋
北恋 2021-01-19 05:11

I am trying to use R to perform an operation (ideally with similarly displayed output) such as

> x<-1:6
> y<-1:6
> x%o%y
     [,1] [,2] [,3] [         


        
2条回答
  •  [愿得一人]
    2021-01-19 05:37

    expand.grid can answer your second question:

    expand.grid(1:6,1:6)
    expand.grid(1:6,1:6,1:4)
    

提交回复
热议问题