从Kolacyzk和Csardi的沙包中运行代码块

时间:2018-05-27 00:29:16

标签: r igraph

我很难理解运算符%o%

same.prac.op <- v.attr.lazega$Practice %o% v.attr.lazega$Practice

此运算符是igraph还是sand的一部分?

https://github.com/kolaczyk/sand/blob/master/sand/inst/code/chapter6.R

1 个答案:

答案 0 :(得分:3)

%o%是外部产品。它是base R。例如,

1:3 %o% 4:6
#      [,1] [,2] [,3]
# [1,]    4    5    6
# [2,]    8   10   12
# [3,]   12   15   18

相当于

matrix(1:3, nc = 1) %*% matrix(4:6, nr = 1)
#      [,1] [,2] [,3]
# [1,]    4    5    6
# [2,]    8   10   12
# [3,]   12   15   18

请参阅https://stat.ethz.ch/R-manual/R-devel/library/base/html/outer.html