日期是整数?如何将整数转换为日期?

时间:2022-08-26 12:37:46

I'm trying to do an analysis of the BTC price here in Brazil, and compare it with other 4 countries..

我正在尝试对巴西的BTC价格进行分析,并将其与其他4个国家进行比较。

So I've found quandl and downloaded their .csv data for both countries.

所以我找到了quandl并为这两个国家下载了他们的.csv数据。

Each .csv has 6 columns:

每个.csv有6列:

  1. Date
  2. 日期
  3. 24h.Average
  4. 24h.Average
  5. Ask
  6. Bid
  7. 出价
  8. Last
  9. 持续
  10. Total.Volume
  11. 总容积

Well, I'm trying to make a new table with:

好吧,我正在尝试制作一个新表:

  1. BTCBRL$Date
  2. BTCBRL $日期
  3. BTCBRL$Last
  4. BTCBRL $最后
  5. BTCUSD$Last
  6. BTCUSD $最后
  7. BTCCNY$Last
  8. BTCCNY $最后
  9. BTCEUR$Last
  10. BTCEUR $最后

So I wrote:

所以我写道:

lastPrices <- cbind(BTCBRL$Date, BTCBRL$Last, BTCUSD$Last, BTCCNY$Last, BTCEUR$Last)

But then my date that once was 2015-07-05, just became 656..

但那时我的约会曾经是2015-07-05,刚刚成为656 ..

What's an efficient to deal with it? Preferably overwriting it in the same table..

处理它有什么效率?最好在同一张表中覆盖它..

1 个解决方案

#1


1  

Use data.frame() rather than cbind() if you want to preserve mixed types (ie have both dates and numeric values). The latter returns a matrix and a matrix can only hold a single atomic data type so it converts everything to numeric.

如果要保留混合类型(即同时具有日期和数值),请使用data.frame()而不是cbind()。后者返回一个矩阵,矩阵只能保存一个原子数据类型,因此它将所有内容转换为数字。

#1


1  

Use data.frame() rather than cbind() if you want to preserve mixed types (ie have both dates and numeric values). The latter returns a matrix and a matrix can only hold a single atomic data type so it converts everything to numeric.

如果要保留混合类型(即同时具有日期和数值),请使用data.frame()而不是cbind()。后者返回一个矩阵,矩阵只能保存一个原子数据类型,因此它将所有内容转换为数字。