-2

我有一个具有上述属性的 data.frame。它本质上是用 Rbbg 下载,然后重新整形,所有的 Nas 都被扔掉了。现在我无法运行任何数学函数,因为我总是收到错误消息“is.numeric(x) || is.logical(x) is not TRUE”。数据框如下所示。有人可以帮助我吗?

最佳安德烈亚斯

date PX_LAST.HSCBCH1M Index PX_LAST.ECC0TR01 Index PX_LAST.USC0TR01 Index PX_LAST.JNC0TR01 Index
193 2003-12-31               231.6578               211.7530               177.7768                 1.1837
194 2004-01-30               239.9991               213.2282               180.3342                 1.2185
195 2004-02-27               246.5998               214.6787               181.1475                 1.1850
196 2004-03-31               244.0620               212.5486               181.9035                 1.2462
197 2004-04-30               241.0590               212.3115               186.3787                 1.2037
198 2004-05-31               240.2047               209.2621               180.3576                 1.1740
    PX_LAST.UKC0TR01 Index PX_LAST.DBSTIB1D Index PX_LAST.TRMMINOK Index PX_LAST.TRMMICAD Index
193               345.7537                39.2328                 18.664                100.362
194               359.2822                38.7778                 18.026                100.362
195               370.2372                39.0448                 18.109                100.362
196               367.7206                38.5325                 18.630                100.362
197               364.3693                39.0558                 19.064                100.362
198               364.7683                38.6902                 18.837                100.362
    PX_LAST.AUC0TR01 Index PX_LAST.TRMMINZD Index PX_LAST.GMUAG Index PX_LAST.SZGATR Index PX_LAST.EUGATR Index
193               144.6399                100.362             182.480              169.092              197.084
194               149.3122                100.362             183.917              169.734              199.239
195               152.5866                100.362             183.802              171.909              202.995
196               151.7402                100.362             186.607              172.833              202.480
197               147.5394                100.362             178.227              171.302              199.941
198               142.0370                100.362             179.959              170.018              195.683
    PX_LAST.USGATR Index PX_LAST.JNGATR Index PX_LAST.UKGATR Index PX_LAST.SWGATR Index PX_LAST.NOGATR Index
193              285.774                2.060              661.739               47.765               46.831
194              291.916                2.129              684.020               47.434               45.605
195              296.681                2.078              709.931               48.312               47.169
196              300.331                2.170              706.912               48.317               48.038
197              297.548                2.089              689.679               48.171               47.906
198              286.870                2.041              683.345               47.697               47.647
    PX_LAST.CAGATR Index PX_LAST.AUGATR Index PX_LAST.NZGATR Index PX_LAST.GEMXEMB1 Index PX_LAST.JPEIGLBL Index
193              250.626              245.142              202.999                71.6518                 351.33
194              251.085              250.856              210.897                72.6657                 357.88
195              253.318              259.029              219.072                73.8771                 360.44
196              261.089              258.816              215.060                75.6680                 370.61
197              251.849              247.467              204.340                75.2113                 358.78
198              243.711              239.527              199.694                72.7642                 341.06
    PX_LAST.IBOXHY Index PX_LAST.BCIW1T Index PX_LAST.SRCATTRR Index PX_LAST.JAUTGLOB Index PX_LAST.MXWO Index
193             142.8033             220.9415                 144.70                170.283          1287.3145
194             146.7751             225.8519                 148.26                175.000          1324.7261
195             146.8187             232.1897                 149.48                177.450          1350.2362
196             147.8032             235.6665                 150.45                178.718          1342.4812
197             152.3135             230.2153                 154.02                177.174          1343.7654
198             144.2304             227.9847                 149.80                171.575          1307.8700
    PX_LAST.MXUS Index PX_LAST.MXEM Index PX_LAST.MXCH Index PX_LAST.MXGB Index PX_LAST.MXASJ Index
193          1298.6043          126.08896             709.77           2988.104            317.1585
194          1338.4509          130.79429             742.24           3033.495            340.0415
195          1357.3877          133.93243             750.31           3186.655            352.3901
196          1338.3062          128.38027             729.76           3084.042            346.6105
197          1347.4045          128.87453             751.14           3127.969            334.5085
198          1317.8738          125.14768             732.10           3074.340            311.1790
    PX_LAST.MXJP Index PX_LAST.MXEF Index PX_LAST.DBCHREF Index PX_LAST.EPEU Index PX_LAST.RUUS Index
193            7.37794           550.0189              1841.532           1951.546          2491.1328
194            7.63641           575.5580              1881.488           2015.318          2632.6620
195            7.64160           603.6149              1868.657           2137.273          2697.5093
196            8.64227           611.0140              1862.560           2177.836          2861.4954
197            8.37291           572.5848              1820.847           2074.689          2519.3947
198            7.88756           540.9759              1832.934           2045.068          2608.8886
    PX_LAST.TPREAL Index PX_LAST.UGAS Index PX_LAST.CMCITR Index PX_LAST.CMPMTR Index PX_LAST.CMIMTR Index
193              7.43896          1233.9518             492.9786             595.9690             324.0602
194              8.42209          1363.7160             509.2115             585.0504             338.8510
195              8.90350          1405.9723             545.4939             585.5482             368.3770
196             10.95698          1484.5974             561.9698             642.2480             368.4301
197             10.17282          1381.7467             558.2269             567.0087             339.5410
198              9.69091          1351.0139             577.0306             576.0891             358.0701
    PX_LAST.CMAGTR Index PX_LAST.CMENTR Index PX_LAST.HEDGNAV Index
193             747.9302             523.2377                356.37
194             791.7329             525.1798                356.37
195             831.2244             572.8937                356.37
196             866.4411             591.3010                376.07
197             865.9421             624.9057                382.72
198             833.8122             673.9791                369.16
4

1 回答 1

0

我可以使用这个重现错误:

cov(data.frame(a=1,b="a"))
#Error: is.numeric(x) || is.logical(x) is not TRUE

所以我假设您的date列(或其他列)是字符或因子变量。当您将数据传递给您正在使用的任何函数时将其排除:

cov(df[,-1])

此外,您应该使用转换日期

df$date <- as.Date(as.character(df$date))
于 2013-10-10T13:30:32.057 回答