【发布时间】:2021-04-19 10:47:53
【问题描述】:
我在 r 中有两个 data.frames。第一个是
cases population urbanisation density temperature h_dev_index
Austria 563.375758 10.7969091 63.07388 134.08690 13.011172 0.9898000
Belgium 109.400000 13.5885455 99.38933 443.52112 16.185297 0.9829455
Bulgaria 0.000000 5.5320606 85.84782 52.30011 20.825068 0.9669576
Croatia 2.000000 3.4548485 64.21382 60.46082 20.855372 0.9288667
第二个是:
估计标准。误差t值Pr(>|t|)
(Intercept) -1.916e+00 7.144e-01 -2.682 0.00785 **
population -7.327e-03 1.572e-03 -4.659 5.37e-06 ***
cases 1.473e-03 1.544e-04 9.541 < 2e-16 ***
urbanisation 3.798e-03 1.962e-03 1.936 0.05410 .
density 8.132e-05 2.512e-04 0.324 0.74641
temperature -3.518e-02 8.641e-03 -4.071 6.43e-05 ***
h_dev_index 1.842e+00 8.800e-01 2.093 0.03743 *
我需要将第二个数据帧的第一列的系数乘以数据帧。结果应该是(对于奥地利):
-1.916e+00 + 563.375758*(-7.327e-03)+ 10.7969091*(1.473e-03)+ 63.07388*(3.798e-03)+134.08690*(8.132e-05)+ 13.011172*(-3.518e-02)+ 0.9898000*1.842e+00
我应该如何解决这个问题?
【问题讨论】:
-
不应该是
10.7969091*(-7.327e-03)之类的吗? -
是的,适用于所有行
-
我添加了一个可能的解决方案。希望有帮助。请注意数据的名称。
标签: r dataframe vector multiplication