对来自单独数据集的乘法矩阵进行故障排除

时间:2019-07-16 20:53:56

标签: r matrix

我一直在整理有关“要求数字/复杂矩阵/矢量参数”问题的先前询问的问题,该问题在尝试将矩阵相乘时出现,但在所提出的解决方案中并未获得成功。我不确定如何组装矩阵或以不同的方式运行它。我要查找的dd1结果对于其余功能至关重要。

我尝试了不同的矩阵运算,例如.matrix,data.matrix,仅矩阵等。我也尝试过str(data)%*%str(data2)。

我在矩阵方面工作不多,所以我不擅长解决问题。

WSRP<- as.matrix(WSRP)
kd<- WSRP[,3:7]
m1 <- as.matrix(c(.2, .05, .1, 0, 0))
dd1 <- kd%*%m1

我的表格显示为:

show(m1)
     [,1] [,2] [,3] [,4] [,5]
[1,]  0.2 0.05  0.1    0    0

show(kd)
      ol     cpx    plag   opx    mt   
 [1,] "0.01" "0.06" "0.16" "0.00" "2.0"
 [2,] "0.01" "0.10" "0.10" "0.02" "2.0"
 [3,] "0.01" "0.28" "0.17" "0.00" "0.0"
 [4,] "0.01" "0.25" "0.08" "0.00" "2.0"
 [5,] "0.01" "0.50" "0.06" "0.05" "1.6"
 [6,] "0.01" "0.50" "0.50" "0.05" "1.0"
 [7,] "0.01" "0.57" "0.06" "0.09" "0.0"
 [8,] "0.00" "0.57" "0.06" "0.00" "1.5"
 [9,] "0.01" "0.62" "0.05" "0.15" "0.0"
[10,] "0.00" "0.66" "0.05" "0.00" "0.0"
[11,] "0.01" "0.62" "0.05" "0.23" "0.0"
[12,] "0.01" "0.63" "0.04" "0.00" "1.5"
[13,] "0.01" "0.60" "0.05" "0.34" "1.4"
[14,] "0.02" "0.50" "0.04" "0.00" "0.0"

我一直收到“ kd%*%m1错误:需要数字/复杂矩阵/矢量参数”消息。

0 个答案:

没有答案