read.zoo 索引中的错误在数据行 2 处有错误条目
Error in read.zoo index has bad entry at data row 2
当我使用下面的 read.zoo 时,效果很好,直到我添加了最后一行:
(我的来源是CSV,但这里是复制格式):
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
最后一行有什么问题?如果删除最后一行,它将起作用!
> 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,如下:
z<-read.zoo(ts1, tz = "UTC", format = "%d/%m/%Y %H:%M", sep = ",")
当我使用下面的 read.zoo 时,效果很好,直到我添加了最后一行: (我的来源是CSV,但这里是复制格式):
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
最后一行有什么问题?如果删除最后一行,它将起作用!
> 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,如下:
z<-read.zoo(ts1, tz = "UTC", format = "%d/%m/%Y %H:%M", sep = ",")