read.zoo 索引中的错误在数据第 2 行有错误的条目 [英] Error in read.zoo index has bad entry at data row 2
本文介绍了read.zoo 索引中的错误在数据第 2 行有错误的条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用以下 read.zoo 时,它一直很好,直到我添加了最后一行:(我的来源是CSV,但这里是复制格式):
When I use the following read.zoo it goes great until I added the last line: (my source is CSV, but here it is in a format for reproducing):
library(zoo)
Lines <- "fdatetime,Consumption
1,27/03/2015 01:00,0.04
2,27/03/2015 02:00,0.04"
> z <- read.zoo(text = Lines, tz = "", format = "%d/%m/%Y %H:%M", sep = ",")
Error in read.zoo(text = Lines, tz = "", format = "%d/%m/%Y %H:%M", sep = ",") :
index has bad entry at data row 51
最后一行有什么问题?如果您删除最后一行,它将起作用!
What's wrong with the last line? If you delete the last line it will work!
> data.table::fread(file.choose(), verbose = TRUE)
Input contains no \n. Taking this to be a filename to open
File opened, filesize is 0.000001 GB.
Memory mapping ... ok
Detected eol as \r\n (CRLF) in that order, the Windows standard.
Positioned on line 1 after skip or autostart
This line is the autostart and not blank so searching up for the last non-blank ... line 1
Detecting sep ... ','
Detected 3 columns. Longest stretch was from line 2 to line 30
Starting data input on line 2 (either column names or first row of data). First 10 characters: 1,25/03/20
Some fields on line 2 are not type character (or are empty). Treating as a data row and using default column names.
Count of eol: 51 (including 0 at the end)
Count of sep: 102
nrow = MIN( nsep [102] / ncol [3] -1, neol [51] - nblank [0] ) = 51
Type codes ( first 5 rows): 143
Type codes (+ middle 5 rows): 143
Type codes (+ last 5 rows): 143
Type codes: 143 (after applying colClasses and integer64)
Type codes: 143 (after applying drop or select (if supplied)
Allocating 3 column slots (3 - 0 dropped)
Read 51 rows. Exactly what was estimated and allocated up front
0.000s ( 0%) Memory map (rerun may be quicker)
0.000s ( 0%) sep and header detection
0.000s ( 0%) Count rows (wc -l)
0.001s (100%) Column type detection (first, middle and last 5 rows)
0.000s ( 0%) Allocation of 51x3 result (xMB) in RAM
0.000s ( 0%) Reading data
0.000s ( 0%) Allocation for type bumps (if any), including gc time if triggered
0.000s ( 0%) Coercing data already read in type bumps (if any)
0.000s ( 0%) Changing na.strings to NA
0.001s Total
推荐答案
感谢 @Henrik,解决方法是指定tz,如下:
Thanks to @Henrik, The solution for it is to specify tz, as followed:
z<-read.zoo(ts1, tz = "UTC", format = "%d/%m/%Y %H:%M", sep = ",")
这篇关于read.zoo 索引中的错误在数据第 2 行有错误的条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文