如何从R中的多个向量和非向量元素列表创建数据帧?

时间:2016-04-11 13:51:16

标签: r dataframe

我尝试从列表中提取具有大于x的基础货币(此处为BTC)的交易量的加密货币对。

这就是列表结构的样子,你可以看到基数和报价货币(例如:USDT_1CR)然后是两种货币的交易量(从基础货币的交易量开始)。

library(RCurl)
library(rjson)
> coins.volumes <- getURL("https://poloniex.com/public?command=return24hVolume")
> coins.volumes <- fromJSON(txt=coins.volumes)
> str(coins.volumes)
    List of 139
     $ USDT_1CR   :List of 2
      ..$ USDT: chr "13087.8971"
      ..$ 1CR:  chr "17052810.9055"
     $ BTC_ABY    :List of 2
      ..$ BTC:  chr "110.576946"
      ..$ ABY:  chr "1184777.93446228"
     $ BTC_YET    :List of 2
      ..$ BTC:  chr "190.547885"
      ..$ YET:  chr "8745777.21445528"

我的目标是创建一个数据框,其中包含BTC中的卷大于100的对,例如:

                vol
BTC_ABY  110.576946
BTC_YET  190.547885

我尝试在列表中循环并使用[[i]][1]选择基本货币的交易量,但在这种情况下,我无法检索报价货币的名称。

 for (i in 1:length(coins.volumes)){

  first(coins.volumes[i])$BTC
  [do stuff here]
  }

所以我的想法是在数据框中转换列表,但由于它包含语言元素(非向量元素),因此无法强制它并保持列表(如文档中所述)。在这种情况下,我稍后无法处理该对象,正如您在此示例中所看到的那样。

> coins.volumes <- as.data.frame(unlist(coins.volumes))
> colnames(coins.volumes) <- "vol"
> head(coins.volumes)
                              vol
USDT_1CR.USDT          1.38782971
USDT_1CR.1CR        1705.28109055
BTC_ABY.BTC            0.57736236
BTC_ABY.ABY      1185677.73446228
BTC_ADN.BTC            120.105021
BTC_ADN.ADN        23700720.45086

> typeof(coins.volumes)
[1] "list"

> class(coins.volumes)
[1] "data.frame"

> str(coins.volumes)
'data.frame':   274 obs. of  1 variable:
 $ unlist(coins.volumes): chr  "1.38782971" "1705.28109055" "0.57736236" "1185677.73446228" ...

> head(subset(coins.volumes, coins.volumes[1]>100))
                                vol
USDT_1CR.USDT            1.38782971
USDT_1CR.1CR          1705.28109055
BTC_AYT.AYT        1184777.93446228
BTC_ASN.ASN          18919.44145086
BTC_ARCH.ARCH        40652.59641626
BTC_BBR.BTC              5.89094062

此处subset(coins.volume, coins.volume[1]>100)无法按预期工作,并返回小于100而不是大于100的值。

我认为解决方案是转换as.numeric然后unlist,但在这种情况下,我丢失了所有对的名称(例如:BTC_ADN)。

as.numeric(unlist(coins.volumes))

创建此数据框的最佳解决方案是什么?过滤卷不是问题,只是创建数据帧的想法将非常感激。

编辑'':添加dput()数据

> dput(coins.data)
structure(c(379.5, 358.00000001, 366.36659, 366.99999998, 365.51, 
380.45052024, 390.30000267, 396.20637602, 413.79564862, 421.9999999, 
417, 449.99999947, 432.870001, 443.99999993, 444.65204624, 462.6, 
453.000001, 454.5, 460, 459.89979983, 438.10101011, 439.7999, 
434.84381765, 445.78999998, 453.06271978, 459.37849927, 418.53822857, 
421.24000002, 423.59556697, 427.00000001, 425.11999918, 430.57315002, 
434.98999999, 436.9499, 428.14, 432.00001111, 430.37677352, 427.50002018, 
451.10000452, 455, 447.42, 447.87047098, 448.44, 446.20000003, 
433.18077498, 429.49640246, 369.99, 381.82436564, 372.5, 384.50000387, 
378.15, 418.00000217, 406.0000001, 380.97271858, 384.12146191, 
406.80087622, 392.17000023, 391.46, 396, 378.0000001, 376.8600002, 
378.66999987, 371.20999998, 374.13999999, 368.6900001, 358.52, 
383.99999998, 383.05700757, 377.63999943, 372.99999933, 374.04999999, 
376.71518383, 383.18, 388.2499994, 387.9999999, 388.88888955, 
402.73, 399, 411.48, 418.00000049, 419, 416.00100053, 436.5000141, 
441.33604503, 439.80001723, 417, 415.31, 421.90905001, 424.00006175, 
429.97999999, 432.84999999, 440, 430.605, 428.8604227, 421.59, 
404, 381.40897331, 409.62721903, 412.59217997, 411.58799993, 
404.60830405, 413.04485222, 418, 411.759998, 403.82640304, 417.29, 
414.73171524, 414.5, 415, 405, 405.71471389, 408.40800004, 406.72188207, 
417.03317652, 417.4205906, 418, 414.91450417, 415.27, 424.69584999, 
421.5200015, 414.69839566, 417.09999968, 415.88519912, 418.96, 
421.92946849, 423.704999, 420.50000777, 424.15999877, 422.92250106, 
422.9, 419.08880001, 417.00910197, 420, 0.00575023, 0.00570001, 
0.00605867, 0.0065, 0.00647401, 0.00591239, 0.00599801, 0.00590007, 
0.00588011, 0.00604403, 0.005877, 0.00601107, 0.00596251, 0.00635708, 
0.00604532, 0.00580912, 0.00591333, 0.00571301, 0.00567197, 0.0056257, 
0.00563009, 0.00560305, 0.00600644, 0.0058206, 0.00619318, 0.00633498, 
0.00666988, 0.00639951, 0.00711105, 0.00737001, 0.0082997, 0.00777944, 
0.00784859, 0.00775023, 0.00756015, 0.00780555, 0.00765384, 0.00785, 
0.00737542, 0.00729992, 0.00709003, 0.00743852, 0.00700804, 0.00676, 
0.00716089, 0.00785, 0.00879028, 0.00999999, 0.01332009, 0.01131012, 
0.0114937, 0.01128001, 0.0125, 0.01299036, 0.01150063, 0.01091964, 
0.01018256, 0.01152032, 0.01081409, 0.01092444, 0.01159, 0.01145, 
0.01113256, 0.01113985, 0.0109909, 0.01123933, 0.01099953, 0.0111098, 
0.01119492, 0.01114, 0.01113432, 0.01056307, 0.00995028, 0.00895, 
0.00989854, 0.00979611, 0.00949498, 0.00959997, 0.00877577, 0.00902118, 
0.00821448, 0.00833031, 0.00829506, 0.0092, 0.00933675, 0.00905222, 
0.00950535, 0.00916702, 0.00927787, 0.0094629, 0.00917127, 0.00890379, 
0.00898489, 0.00907603, 0.01090612, 0.01125, 0.01264001, 0.01131568, 
0.01050145, 0.01098571, 0.01108398, 0.01160204, 0.01229617, 0.01300825, 
0.01354523, 0.01329955, 0.01385207, 0.01515536, 0.01395944, 0.01468, 
0.0145005, 0.01467919, 0.01478308, 0.01443178, 0.01567795, 0.01600761, 
0.01780501, 0.01719321, 0.01626003, 0.01656103, 0.01693851, 0.01687999, 
0.01660369, 0.01690755, 0.01674544, 0.01662832, 0.01648424, 0.01665213, 
0.01654329, 0.01639719, 0.01662339, 0.01586999, 0.01555429, 0.00104272, 
0.00104528, 0.0010302, 0.00101005, 0.00102, 0.00112788, 0.0011252, 
0.0010667, 0.00105593, 0.00108114, 0.00105247, 0.00101413, 0.00104971, 
0.00105402, 0.00122244, 0.001179, 0.00113753, 0.00109229, 0.00107071, 
0.00105198, 0.00115682, 0.00114121, 0.001094, 0.00107257, 0.00105713, 
0.00107009, 0.00107681, 0.001058, 0.00106686, 0.00105697, 0.0010313, 
0.0010505, 0.00115864, 0.00121077, 0.00114551, 0.00115925, 0.00116556, 
0.001183, 0.00107387, 0.00109811, 0.00110032, 0.00109516, 0.00108453, 
0.0011285, 0.00112387, 0.00114216, 0.00117463, 0.00129117, 0.00112577, 
0.00129104, 0.00137767, 0.00127763, 0.00136008, 0.00140798, 0.00162659, 
0.00154971, 0.00148704, 0.00150398, 0.00153617, 0.00148112, 0.00135203, 
0.00134102, 0.00131003, 0.00133091, 0.00132054, 0.00134496, 0.00130208, 
0.00127503, 0.00130593, 0.00126759, 0.00129017, 0.00124812, 0.00125019, 
0.0014598, 0.00155585, 0.00199147, 0.0021, 0.00193695, 0.00232267, 
0.00173952, 0.00184298, 0.00201151, 0.0018796, 0.00176129, 0.00179101, 
0.00178997, 0.00187798, 0.00189483, 0.00189962, 0.0019007, 0.00200984, 
0.00198607, 0.00194999, 0.00194375, 0.0025647, 0.00285798, 0.00298006, 
0.00307496, 0.00248278, 0.002823, 0.00295501, 0.0025857, 0.00262977, 
0.00280011, 0.00297992, 0.00270975, 0.00276297, 0.00275458, 0.00323086, 
0.00280432, 0.00297347, 0.00364169, 0.0035493, 0.00325784, 0.00347735, 
0.00397744, 0.00386055, 0.00404742, 0.00358535, 0.00350996, 0.0035684, 
0.00349897, 0.00338059, 0.00347389, 0.00372897, 0.00368965, 0.00378727, 
0.00355113, 0.00354698, 0.00361764, 0.00339187, 0.00278487, 0.00258499, 
4.4e-07, 5.5e-07, 5.3e-07, 5.1e-07, 5e-07, 4.2e-07, 4.1e-07, 
4.2e-07, 4.2e-07, 3.8e-07, 3.5e-07, 3.4e-07, 3.7e-07, 3.4e-07, 
3.7e-07, 3.3e-07, 3.2e-07, 3.2e-07, 3e-07, 3.1e-07, 2.9e-07, 
2.9e-07, 2.8e-07, 2.8e-07, 3.1e-07, 3.4e-07, 3.1e-07, 3.1e-07, 
3.3e-07, 3e-07, 3e-07, 3.2e-07, 3e-07, 3e-07, 3e-07, 2.9e-07, 
3.1e-07, 3e-07, 3e-07, 3e-07, 4.4e-07, 4.8e-07, 3.8e-07, 3.5e-07, 
3.2e-07, 3.4e-07, 3.5e-07, 3.5e-07, 3.2e-07, 3.2e-07, 3.1e-07, 
3.5e-07, 3.8e-07, 3.9e-07, 3.6e-07, 3.5e-07, 3.4e-07, 3.9e-07, 
4.1e-07, 4.5e-07, 5.1e-07, 5.2e-07, 4.6e-07, 4.4e-07, 4.5e-07, 
4.3e-07, 4.1e-07, 4.1e-07, 4.7e-07, 4.3e-07, 4.5e-07, 4.4e-07, 
4.5e-07, 4.6e-07, 9e-07, 6.8e-07, 5.5e-07, 5.6e-07, 5.5e-07, 
5.2e-07, 5e-07, 4.9e-07, 4.8e-07, 4.5e-07, 5.2e-07, 5.1e-07, 
5.1e-07, 4.8e-07, 4.9e-07, 5e-07, 4.8e-07, 4.8e-07, 5.5e-07, 
6.1e-07, 6.3e-07, 5.7e-07, 5.3e-07, 5.2e-07, 5.2e-07, 5.5e-07, 
5.6e-07, 5.4e-07, 5.5e-07, 5.2e-07, 5.1e-07, 4.8e-07, 5.2e-07, 
5.2e-07, 8.5e-07, 6.9e-07, 7.1e-07, 6.7e-07, 7.4e-07, 8.6e-07, 
7.5e-07, 7.8e-07, 1.08e-06, 1.51e-06, 1.44e-06, 1.55e-06, 1.58e-06, 
1.59e-06, 1.35e-06, 1.3e-06, 1.22e-06, 1.13e-06, 1.18e-06, 9.7e-07, 
1.04e-06, 1.02e-06, 9.6e-07, 9.1e-07, 9.4e-07, 4.47e-06, 4.4e-06, 
4.58e-06, 4.6e-06, 4.88e-06, 4.53e-06, 4.68e-06, 4.67e-06, 5.56e-06, 
5.62e-06, 5.5e-06, 4.76e-06, 4.64e-06, 4.66e-06, 4.51e-06, 3.96e-06, 
4e-06, 4.04e-06, 3.97e-06, 3.95e-06, 3.91e-06, 4.08e-06, 3.91e-06, 
3.96e-06, 3.93e-06, 3.85e-06, 4e-06, 4.13e-06, 4.06e-06, 4.09e-06, 
4.16e-06, 4.1e-06, 4.04e-06, 4.14e-06, 4.08e-06, 4.06e-06, 3.93e-06, 
3.82e-06, 3.78e-06, 3.84e-06, 3.9e-06, 3.93e-06, 3.85e-06, 3.89e-06, 
4.16e-06, 4.18e-06, 4.51e-06, 4.54e-06, 4.26e-06, 4.37e-06, 4.97e-06, 
4.34e-06, 4.17e-06, 4.55e-06, 4.28e-06, 4.19e-06, 4.36e-06, 4.6e-06, 
5.02e-06, 5.12e-06, 5.01e-06, 4.8e-06, 4.54e-06, 4.75e-06, 4.87e-06, 
4.96e-06, 4.61e-06, 4.61e-06, 4.94e-06, 4.68e-06, 4.89e-06, 4.79e-06, 
4.82e-06, 4.96e-06, 5.86e-06, 5.7e-06, 5.17e-06, 5.56e-06, 6.22e-06, 
4.8e-06, 5e-06, 5.13e-06, 4.67e-06, 4.85e-06, 4.47e-06, 4.47e-06, 
4.49e-06, 4.5e-06, 4.43e-06, 4.74e-06, 4.52e-06, 4.32e-06, 4.3e-06, 
4.3e-06, 4.44e-06, 4.62e-06, 4.37e-06, 4.62e-06, 5.84e-06, 5.4e-06, 
5.63e-06, 5.5e-06, 6.15e-06, 5.36e-06, 5.11e-06, 5e-06, 5.07e-06, 
5.03e-06, 5.12e-06, 4.88e-06, 5.06e-06, 5e-06, 5.04e-06, 4.99e-06, 
5.05e-06, 4.96e-06, 5.05e-06, 4.95e-06, 4.69e-06, 4.95e-06, 4.92e-06, 
4.86e-06, 4.76e-06, 4.85e-06, 4.93e-06, 5.07e-06, 5.43e-06, 5.05e-06, 
5.09e-06, 5.08e-06, 5.16e-06, 4.74e-06, 4.39e-06, 1.33e-06, 1.36e-06, 
1.37e-06, 1.31e-06, 1.28e-06, 1.4e-06, 1.28e-06, 1.18e-06, 1.11e-06, 
1.03e-06, 1.12e-06, 1.07e-06, 1.07e-06, 1e-06, 9.9e-07, 1.01e-06, 
1e-06, 1.05e-06, 1e-06, 9.8e-07, 1e-06, 9.8e-07, 9.8e-07, 9.2e-07, 
1e-06, 9.4e-07, 9.6e-07, 1e-06, 1.08e-06, 1.12e-06, 1.05e-06, 
1.11e-06, 1.11e-06, 9.6e-07, 9.8e-07, 1.01e-06, 9.8e-07, 9.8e-07, 
1e-06, 9.6e-07, 1.02e-06, 9.5e-07, 9.3e-07, 9.6e-07, 9.9e-07, 
1.1e-06, 9.5e-07, 9.5e-07, 8.9e-07, 9.3e-07, 9e-07, 8.8e-07, 
9.4e-07, 1e-06, 1.05e-06, 1e-06, 9.1e-07, 1.2e-06, 1.6e-06, 1.26e-06, 
1.38e-06, 1.4e-06, 1.34e-06, 1.3e-06, 1.36e-06, 1.54e-06, 1.5e-06, 
1.45e-06, 1.42e-06, 1.46e-06, 1.44e-06, 1.52e-06, 1.47e-06, 1.45e-06, 
1.9e-06, 2.6e-06, 2.6e-06, 2.51e-06, 2.58e-06, 2.73e-06, 3.11e-06, 
6e-06, 5.54e-06, 7.82e-06, 5.8e-06, 5.18e-06, 5.39e-06, 5.6e-06, 
7.62e-06, 8.38e-06, 1.073e-05, 7.63e-06, 7.24e-06, 7.34e-06, 
7.18e-06, 7.01e-06, 6.37e-06, 7.15e-06, 6.89e-06, 7.71e-06, 7.96e-06, 
8.49e-06, 1.007e-05, 9.68e-06, 9.65e-06, 1.193e-05, 1.595e-05, 
2.285e-05, 2.781e-05, 2.211e-05, 2.385e-05, 2.132e-05, 2.222e-05, 
2.023e-05, 2.212e-05, 1.999e-05, 1.996e-05, 1.925e-05, 1.574e-05, 
1.769e-05, 1.677e-05, 1.866e-05, 2.134e-05, 2.089e-05, 1.999e-05, 
2.006e-05, 2.239e-05, 1.986e-05, 1.938e-05, 1.992e-05, 1.993e-05, 
1.906e-05, 1.712e-05, 3.904e-05, 4.095e-05, 3.753e-05, 3.73e-05, 
3.699e-05, 3.317e-05, 3.436e-05, 3.282e-05, 2.993e-05, 3.021e-05, 
4e-05, 3.179e-05, 3.336e-05, 3.3e-05, 3.284e-05, 2.889e-05, 2.975e-05, 
3e-05, 3.032e-05, 3.083e-05, 3.057e-05, 3.028e-05, 5.1e-05, 3.88e-05, 
3.769e-05, 3.546e-05, 3.486e-05, 3.606e-05, 3.54e-05, 3.485e-05, 
3.7e-05, 3.661e-05, 3.768e-05, 3.704e-05, 3.6e-05, 3.601e-05, 
3.878e-05, 3.971e-05, 3.775e-05, 3.525e-05, 3.78e-05, 3.514e-05, 
3.611e-05, 4.67e-05, 4.802e-05, 4.364e-05, 4.619e-05, 4.708e-05, 
4.899e-05, 4.756e-05, 4.944e-05, 5.064e-05, 5.722e-05, 5.714e-05, 
5.935e-05, 5.885e-05, 5.999e-05, 6.96e-05, 7.163e-05, 6.976e-05, 
7.452e-05, 7.609e-05, 7.699e-05, 7.505e-05, 7.581e-05, 8.878e-05, 
9.301e-05, 9.295e-05, 9.697e-05, 9e-05, 9.259e-05, 9.266e-05, 
9.405e-05, 0.00011256, 0.00012434, 0.000127, 0.00013641, 0.00012333, 
0.00012004, 0.00010109, 0.00010774, 9.882e-05, 8.825e-05, 8.67e-05, 
9.349e-05, 9.84e-05, 0.00010695, 0.00012223, 0.0001269, 0.0001269, 
0.00011252, 0.00010718, 0.00010748, 0.0001085, 0.00011631, 0.00012702, 
0.00014367, 0.00023026, 0.00020037, 0.00021503, 0.00023797, 0.00025, 
0.00024689, 0.00026014, 0.000216, 0.00023492, 0.00019857, 0.0002089, 
0.00019129, 0.00019453, 0.00020716, 0.00020345, 0.00020411, 0.00021472, 
0.00022529, 0.00024449, 0.00026225, 0.00023591, 0.0002175, 0.00021275, 
0.00020401, 0.00021173, 0.00021603, 0.00019545, 0.00020047, 0.00019229, 
0.00020131, 0.00020137, 0.00022334, 0.00022273, 0.00026731, 0.00023382, 
0.00023166, 3.304e-05, 3.423e-05, 3.425e-05, 3.496e-05, 3.512e-05, 
3.572e-05, 3.929e-05, 3.741e-05, 3.997e-05, 3.936e-05, 3.918e-05, 
3.903e-05, 3.871e-05, 3.824e-05, 3.507e-05, 3.226e-05, 3.447e-05, 
3.294e-05, 3.337e-05, 3.381e-05, 3.408e-05, 3.301e-05, 3.482e-05, 
3.116e-05, 3.25e-05, 3.209e-05, 3.297e-05, 3.419e-05, 3.288e-05, 
3.233e-05, 3.289e-05, 3.38e-05, 3.317e-05, 3.395e-05, 3.496e-05, 
3.586e-05, 3.554e-05, 4.154e-05, 3.667e-05, 3.863e-05, 3.807e-05, 
3.786e-05, 3.923e-05, 3.98e-05, 3.917e-05, 3.936e-05, 4.05e-05, 
3.927e-05, 3.893e-05, 5.081e-05, 4.906e-05, 3.968e-05, 4.026e-05, 
4.263e-05, 4.509e-05, 4.704e-05, 4.641e-05, 5.197e-05, 5.859e-05, 
5.766e-05, 5.115e-05, 5.509e-05, 5.395e-05, 5.138e-05, 4.888e-05, 
4.879e-05, 5.164e-05, 5.364e-05, 5.286e-05, 5.581e-05, 5.476e-05, 
5.535e-05, 7.306e-05, 9.166e-05, 0.00010597, 9.874e-05, 0.00011039, 
0.0001299, 0.00011909, 0.00010716, 0.00011264, 0.00012203, 0.0001175, 
0.00012641, 0.00013002, 0.00014842, 0.00016347, 0.00015832, 0.00016684, 
2e-04, 0.00020295, 0.00020687, 0.00018431, 0.00020329, 0.00023146, 
0.00023715, 0.00028029, 0.00025436, 0.00026255, 0.00025346, 0.00026248, 
0.00026983, 0.00026401, 0.00025888, 0.00023793, 0.0002196, 0.00024699, 
0.00023778, 0.00019668, 0.00019505, 0.000205, 0.00019805, 0.00022998, 
0.00022, 0.00022015, 0.000248, 0.00023537, 0.00021882, 0.00020414, 
0.0002112, 0.00021004, 0.000202, 0.0001945, 0.00019231, 0.0001907, 
0.0001934, 0.00019587, 0.00018308, 0.00017903, 0.00017953, 0.00018174, 
0.00017839, 0.00015939, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 0.01330144, 0.00059898, 0.00039148, 0.00042809, 0.00108, 
0.00094015, 0.00063, 0.00068948, 0.00067949, 0.00068981, 0.00065867, 
0.00066055, 0.00065326, 0.00075101, 0.00089555, 0.0007904, 0.00072222, 
0.00072643, 0.00090199, 0.00088884, 0.00091531, 0.00098582, 0.00107119, 
0.00101975, 0.0009642, 0.00091978, 0.00081613, 0.00080831, 0.00079061, 
0.0008595, 0.00082333, 0.00080178, 0.00100176, 0.0010473, 0.00104217, 
0.00112294, 0.00173468, 0.00190012, 0.001835, 0.00181218, 0.00157862, 
0.00136222, 0.00147079, 0.00149283, 0.00153158, 0.00152148, 0.00152123, 
0.00151522, 0.00147258, 0.00147643, 0.00148537, 0.00142856, 0.00154899, 
0.00165459, 0.00156768, 0.00129449, 0.00231785, 0.00240705, 0.00228976, 
0.00228, 0.00232459, 0.00219997, 0.00212882, 0.002015, 0.002, 
0.00189089, 0.00202, 0.00203835, 0.00224993, 0.00219601, 0.00223344, 
0.002199, 0.00219664, 0.00206823, 0.00197002, 0.00195134, 0.00203521, 
0.00204111, 0.00199058, 0.00191003, 0.00188043, 0.00191, 0.00205005, 
0.00201267, 0.00200001, 0.00202056, 0.00213656, 0.00216513, 0.00215209, 
0.00215098, 0.00225072, 0.00218092, 0.00220501, 0.00222223, 0.00207652, 
0.00216979, 0.00218896, 0.0022275, 0.00233401, 0.00258081, 0.00262208, 
0.00272941, 0.00326988, 0.00315998, 0.00341884, 0.00363508, 0.00358923, 
0.00370199, 0.00378318, 0.003895, 0.00521, 0.00526097, 0.00626864, 
0.00550994, 0.0061, 0.0066398, 0.00655773, 0.00643708, 0.00633012, 
0.00596006, 0.00646492, 0.00678111, 0.0066, 0.00654998, 0.00670102, 
0.00783876, 0.00859999, 0.00989203, 0.0116998, 0.015953, 0.014351, 
0.01341946, 0.0126311, 0.01309005, 0.0107, 0.008852, 0.0103, 
0.01066002, 0.00974203, 0.01073885, 0.012909, 0.01331927, 0.014578, 
0.01399, 0.01388995, 0.01472999, 0.01489, 0.01445, 0.01756666, 
0.0198, 0.02264987, 0.02457, 0.027707, 0.02735002, 0.02271001, 
0.02350854, 0.02887999, 0.026915, 0.02674, 0.032606, 0.03619991, 
0.030245, 0.03103846, 0.030887, 0.026235, 0.02629243, 0.02555394, 
0.02460892, 0.02887999, 0.027, 0.029789, 0.02680799, 0.025575, 
0.02652499, 0.02435701, 0.02766899, 0.0283, 0.028629, 0.027199, 
0.027969, 0.02753937, 0.027523, 0.026521, 0.02452622, 0.025463, 
0.023868, 0.023253, 0.02194772, 0.02092458, 3.3e-07, 3.4e-07, 
3.5e-07, 3.4e-07, 3.5e-07, 3.2e-07, 3.1e-07, 3.2e-07, 3.1e-07, 
3.3e-07, 3.2e-07, 3e-07, 3.1e-07, 3e-07, 3e-07, 3e-07, 2.9e-07, 
3e-07, 3.1e-07, 2.9e-07, 3e-07, 3.1e-07, 3e-07, 3.1e-07, 3.1e-07, 
3e-07, 3.3e-07, 3.3e-07, 3.1e-07, 3.1e-07, 3.2e-07, 3.1e-07, 
3.1e-07, 3.2e-07, 3.1e-07, 3.2e-07, 3.2e-07, 3.1e-07, 3.1e-07, 
3.4e-07, 4e-07, 3.7e-07, 3.8e-07, 4.1e-07, 4.1e-07, 4e-07, 4e-07, 
4e-07, 4e-07, 3.9e-07, 3.9e-07, 3.9e-07, 3.9e-07, 4.3e-07, 4.5e-07, 
4.7e-07, 5.4e-07, 8.5e-07, 1.15e-06, 9e-07, 8.4e-07, 6.7e-07, 
7.1e-07, 7e-07, 7e-07, 7.2e-07, 7.4e-07, 7.8e-07, 8e-07, 7.4e-07, 
7.6e-07, 7.7e-07, 7.6e-07, 7.4e-07, 7.6e-07, 7.4e-07, 7.2e-07, 
7.2e-07, 6.9e-07, 6.5e-07, 6.5e-07, 6.8e-07, 6.6e-07, 6.5e-07, 
6.5e-07, 6.5e-07, 6.5e-07, 6.3e-07, 6e-07, 5.8e-07, 5.8e-07, 
5.6e-07, 5.7e-07, 5.6e-07, 5.7e-07, 5.7e-07, 5.5e-07, 5.4e-07, 
5.6e-07, 5.3e-07, 5.6e-07, 5.8e-07, 5.8e-07, 5.8e-07, 5.9e-07, 
5.7e-07, 5.6e-07, 5.5e-07, 5.3e-07, 5.1e-07, 5.4e-07, 5.1e-07, 
5.1e-07, 5.2e-07, 5.2e-07, 5.1e-07, 5.1e-07, 5e-07, 5e-07, 5e-07, 
6.2e-07, 5.6e-07, 5.6e-07, 5.4e-07, 5.4e-07, 5.2e-07, 5.2e-07, 
5.1e-07, 5.1e-07, 4.9e-07, 5.1e-07, 4.9e-07, 4.8e-07, 0.0002998, 
0.0002527, 0.00024468, 0.00021729, 0.00025549, 0.00022605, 0.00022839, 
0.00022871, 0.00022876, 0.00022025, 0.00023, 0.00017987, 0.00018368, 
0.00017209, 0.00017994, 0.00025, 0.00022, 0.0002169, 0.000288, 
0.00040803, 0.00064597, 0.001593, 0.00121, 0.00096554, 0.00087428, 
0.00087998, 0.001102, 0.00106, 0.00102718, 0.00092975, 0.00107198, 
0.00104989, 0.0013509, 0.00154557, 0.0014891, 0.00138396, 0.00141504, 
0.00143118, 0.00124749, 0.00169488, 0.00174738, 0.0016001, 0.0016999, 
0.00277248, 0.00274304, 0.00262792, 0.00255346, 0.00231994, 0.00251107, 
0.00244875, 0.00227001, 0.00221312, 0.00243214, 0.00267434, 0.00265491, 
0.00255999, 0.00237757, 0.00311377, 0.00312137, 0.00283, 0.00261806, 
0.00262999, 0.00238439, 0.002379, 0.00210977, 0.00227968, 0.00239801, 
0.00264, 0.00261122, 0.00252167, 0.00268501, 0.00255, 0.00297999, 
0.00305013, 0.00294088, 0.00271931, 0.00273909, 0.00273868, 0.00283597, 
0.00247834, 0.002475, 0.00247433, 0.00232022, 0.00230184, 0.00220022, 
0.00227615, 0.00253104, 0.00249086, 0.00234615, 0.00237541, 0.00246367, 
0.0023214, 0.00220099, 0.00238204, 0.00259219, 0.00289999, 0.00436989, 
0.00510849, 0.0057828, 0.00786, 0.00706999, 0.00597493, 0.00573323, 
0.00600793, 0.00586653, 0.0049849, 0.00518083, 0.00459982, 0.00399501, 
0.00367715, 0.00431188, 0.00379901, 0.00419926, 0.0041979, 0.00444515, 
0.00426247, 0.00435615, 0.00436523, 0.00399998, 0.00404728, 0.00427805, 
0.00415573, 0.00407699, 0.00399999, 0.00380424, 0.00395101, 0.00394104, 
0.00380866, 0.00365385, 0.0036067, 0.00362287, 0.00357754, 0.00286019, 
8.54e-06, 8.83e-06, 8.62e-06, 8.74e-06, 9.37e-06, 8.77e-06, 8.55e-06, 
8.64e-06, 9.04e-06, 8.97e-06, 8.86e-06, 8.89e-06, 8.5e-06, 8.42e-06, 
8.25e-06, 7.93e-06, 8.04e-06, 8.03e-06, 7.85e-06, 7.69e-06, 7.89e-06, 
8.16e-06, 7.99e-06, 7.59e-06, 7.48e-06, 7.71e-06, 7.98e-06, 8.4e-06, 
8.11e-06, 7.98e-06, 8.18e-06, 8.09e-06, 7.99e-06, 7.91e-06, 7.9e-06, 
7.8e-06, 7.78e-06, 7.55e-06, 6.29e-06, 5.97e-06, 6.8e-06, 6.62e-06, 
6.66e-06, 7e-06, 7.35e-06, 7.3e-06, 8.07e-06, 7.98e-06, 7.79e-06, 
7.79e-06, 7.89e-06, 7.57e-06, 7.47e-06, 7.85e-06, 7.71e-06, 7.58e-06, 
7.94e-06, 8.82e-06, 9.84e-06, 9.59e-06, 9.33e-06, 8.78e-06, 9.09e-06, 
9.12e-06, 8.82e-06, 8.7e-06, 8.42e-06, 8.56e-06, 8.71e-06, 9.63e-06, 
8.94e-06, 8.83e-06, 8.94e-06, 9.67e-06, 1.257e-05, 1.153e-05, 
1.078e-05, 1.17e-05, 1.252e-05, 1.012e-05, 1.016e-05, 1.027e-05, 
9.29e-06, 9.35e-06, 9.43e-06, 1.002e-05, 9.59e-06, 9.36e-06, 
9.58e-06, 9.33e-06, 9.49e-06, 9.11e-06, 9.14e-06, 9.08e-06, 9.43e-06, 
1.002e-05, 1.015e-05, 1.306e-05, 1.097e-05, 1.184e-05, 1.206e-05, 
1.966e-05, 1.861e-05, 1.959e-05, 1.741e-05, 1.458e-05, 1.524e-05, 
1.58e-05, 1.395e-05, 1.328e-05, 1.411e-05, 1.34e-05, 1.541e-05, 
1.456e-05, 1.465e-05, 1.39e-05, 1.459e-05, 1.6e-05, 1.453e-05, 
1.424e-05, 1.416e-05, 1.482e-05, 1.422e-05, 1.415e-05, 1.4e-05, 
1.417e-05, 1.472e-05, 1.437e-05, 1.419e-05, 1.389e-05, 1.363e-05, 
1.343e-05, 1.192e-05), .Dim = c(133L, 13L), .Dimnames = list(
    NULL, c("BTC", "DASH", "XMR", "DGB", "STR", "SYS", "SJCX", 
    "MAID", "RADS", "ETH", "DOGE", "FCT", "BTS")), index = structure(c(1448928000, 
1449014400, 1449100800, 1449187200, 1449273600, 1449360000, 1449446400, 
1449532800, 1449619200, 1449705600, 1449792000, 1449878400, 1449964800, 
1450051200, 1450137600, 1450224000, 1450310400, 1450396800, 1450483200, 
1450569600, 1450656000, 1450742400, 1450828800, 1450915200, 1451001600, 
1451088000, 1451174400, 1451260800, 1451347200, 1451433600, 1451520000, 
1451606400, 1451692800, 1451779200, 1451865600, 1451952000, 1452038400, 
1452124800, 1452211200, 1452297600, 1452384000, 1452470400, 1452556800, 
1452643200, 1452729600, 1452816000, 1452902400, 1452988800, 1453075200, 
1453161600, 1453248000, 1453334400, 1453420800, 1453507200, 1453593600, 
1453680000, 1453766400, 1453852800, 1453939200, 1454025600, 1454112000, 
1454198400, 1454284800, 1454371200, 1454457600, 1454544000, 1454630400, 
1454716800, 1454803200, 1454889600, 1454976000, 1455062400, 1455148800, 
1455235200, 1455321600, 1455408000, 1455494400, 1455580800, 1455667200, 
1455753600, 1455840000, 1455926400, 1456012800, 1456099200, 1456185600, 
1456272000, 1456358400, 1456444800, 1456531200, 1456617600, 1456704000, 
1456790400, 1456876800, 1456963200, 1457049600, 1457136000, 1457222400, 
1457308800, 1457395200, 1457481600, 1457568000, 1457654400, 1457740800, 
1457827200, 1457913600, 1.458e+09, 1458086400, 1458172800, 1458259200, 
1458345600, 1458432000, 1458518400, 1458604800, 1458691200, 1458777600, 
1458864000, 1458950400, 1459036800, 1459123200, 1459209600, 1459296000, 
1459382400, 1459468800, 1459555200, 1459641600, 1459728000, 1459814400, 
1459900800, 1459987200, 1460073600, 1460160000, 1460246400, 1460332800
), tzone = structure("UTC", .Names = "TZ"), tclass = "Date"), class = c("xts", 
"zoo"), .indexCLASS = "Date", .indexTZ = structure("UTC", .Names = "TZ"), tclass = c("POSIXct", 
"POSIXt"), tzone = structure("UTC", .Names = "TZ"))

编辑:添加列表的structure

> head(structure(coins.volumes))
$BTC_1CR
$BTC_1CR$BTC
[1] "1.65816128"

$BTC_1CR$`1CR`
[1] "2008.64938599"


$BTC_ABY
$BTC_ABY$BTC
[1] "0.83078577"

$BTC_ABY$ABY
[1] "1679333.10356384"


$BTC_ADN
$BTC_ADN$BTC
[1] "0.20472476"

$BTC_ADN$ADN
[1] "29634.34146836"


$BTC_ARCH
$BTC_ARCH$BTC
[1] "0.22979850"

$BTC_ARCH$ARCH
[1] "32173.19309997"


$BTC_BBR
$BTC_BBR$BTC
[1] "5.66801943"

$BTC_BBR$BBR
[1] "98579.06094324"


$BTC_BCN
$BTC_BCN$BTC
[1] "4.78475521"

$BTC_BCN$BCN
[1] "48259301.26876716"

谢谢

1 个答案:

答案 0 :(得分:2)

我认为以下内容适用于您示例中的数据:

# use your for loop to get the list of values
coins.values <- numeric(length=length(coins.volumes))
for (i in 1:length(coins.volumes)){
  coins.values[i] <- as.numeric(coins.volumes[[i]][1])
}
# use the names function to get the desired names
coins.names <- names(coins.volumes)

# make a data.frame
newData <- data.frame("names"=coins.names, "values"=coins.values)