我有一个向量v
和一个矩阵m
。我想在 R 中得到以下结果。我该怎么做?
v = c(1, 2)
m = matrix(c(1, 0, 1, 1, 0, 2.5, 3.5, 4.3, 2, 5.5), nrow = 5)
result = matrix(c(1, 0, 1, 1, 0, 5, 7, 8.6, 4, 11), nrow = 5)
> result
[,1] [,2]
[1,] 1 5.0
[2,] 0 7.0
[3,] 1 8.6
[4,] 1 4.0
[5,] 0 11.0