数据表中的结果相同

时间:2018-02-01 17:13:21

标签: r dataframe sum dplyr data.table

我有一张表格,其中包含一些货币和这种货币的头寸价值。我想总结那些按货币分组的价值观。当我这样做时:

Dane2[,sum(Dane2$LPB), by = Dane2$CurrencyBase]

我明白了:

Dane       V1
1:  USD 29552732
2:  AUD 29552732
3:  BTC 29552732
4:  CAD 29552732
5:  CHF 29552732
6:  DSH 29552732
7:  EUR 29552732
8:  ETH 29552732
9:  GBP 29552732
10:  LTC 29552732
11:  NZD 29552732
12:  XRP 29552732
13:  PLN 29552732

但当然这些并不是表中的真正价值。哪里出错了?

1 个答案:

答案 0 :(得分:3)

我建议使用const initializeApp = () => { const resolver = (res) => { if (window.AppApi) { res(true); } else { setTimeout(resolver, 250, res); } } return new Promise(( resolve, reject ) => { resolver(resolve) }); }; initializeApp().then(( result ) => { console.log( 'it worked!' ); }); setTimeout(() => { console.log("Setting api"); window.AppApi = {} }, 2000);函数并对值进行求和:

aggregate()

当数据框中的列增长时,此功能特别有用。