I truncated and simplified my code and the read in data that I'm working with to isolate the issue. Here is the read in data and R script respectively: http://r.789695.n4.nabble.com/file/n4604287/test.csv test.csv http://pastebin.com/rCdaDqPm Here is the terminal/R shell output that I hope the above replicates on your screen:> source("elecLoad.r", echo = TRUE)> #Load packages > library(zoo)> library(chron)> #Initial assignments for format (fmt), timezone (TZ), and user > #defined chron function (chr) > fmt = "%m/%d/%y %I:%M %p"> TZ = "PDT"> chr = function(x) as.chron(x, fmt)> #Read in data as zoo object using relevant arguments in read.zoo() > #for details of arguments, see Kevin Navero or see ?read.zoo > #and ?read.table .... [TRUNCATED]Error in read.zoo("http://dl.dropbox.com/u/41922443/test.csv", skip = 1, : index has bad entries at data rows: 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 I was hoping that the "NULL" in colClasses() would've taken care of this uneven vector length issue, however, that was not the case. Any ideas? Thanks in advance. Sorry if my post didn't follow the forum rules exactly. I tried to make small scale reproducible code and what not. I'm still a bit of a noob here and there. -- View this message in context: http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287.html Sent from the R help mailing list archive at Nabble.com.
So far I see two options: (1) nrows argument to specify max number of rows to read in or (2) go into excel, and put a bunch of NA's . Both which are inefficient in that they're not so "automated". For case (1), I have to wait till an error pops up each time and deal with each one individually taking into account the skip and header args, and for case (2), now I'm just not even using R to do the dirty work...anyway, I'm going to continue to go through this R documentation to see if I find anything else for ?read.table and ?read.zoo. -- View this message in context: http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604323.html Sent from the R help mailing list archive at Nabble.com.
Make that 3 options actually. In case (3) I would have to take each category on the spreadsheet and isolate each to its own csv file using excel. Fun stuff... -- View this message in context: http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604329.html Sent from the R help mailing list archive at Nabble.com.
Case (4) - use the fill argument in ?read.table....this looks useful...guess I answered my own question...going to delete this thread now... -- View this message in context: http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604332.html Sent from the R help mailing list archive at Nabble.com.
case (6) - regress back to read.table apparently.... -- View this message in context: http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604537.html Sent from the R help mailing list archive at Nabble.com.
On Wed, May 2, 2012 at 3:55 PM, knavero <knavero at gmail.com> wrote:> I truncated and simplified my code and the read in data that I'm working with > to isolate the issue. Here is the read in data and R script respectively: > > http://r.789695.n4.nabble.com/file/n4604287/test.csv test.csv > > http://pastebin.com/rCdaDqPm > > Here is the terminal/R shell output that I hope the above replicates on your > screen: >> source("elecLoad.r", echo = TRUE) > >> #Load packages >> library(zoo) > >> library(chron) > >> #Initial assignments for format (fmt), timezone (TZ), and user >> #defined chron function (chr) >> fmt = "%m/%d/%y %I:%M %p" > >> TZ = "PDT" > >> chr = function(x) as.chron(x, fmt) > >> #Read in data as zoo object using relevant arguments in read.zoo() >> #for details of arguments, see Kevin Navero or see ?read.zoo >> #and ?read.table .... [TRUNCATED] > Error in read.zoo("http://dl.dropbox.com/u/41922443/test.csv", skip = 1, ?: > ?index has bad entries at data rows: 14 15 16 17 18 19 20 21 22 23 24 25 26 > 27 28 > > I was hoping that the "NULL" in colClasses() would've taken care of this > uneven vector length issue, however, that was not the case. Any ideas? > Thanks in advance. Sorry if my post didn't follow the forum rules exactly. I > tried to make small scale reproducible code and what not. I'm still a bit of > a noob here and there. >Try this using the same library statements, fmt and chr from ijn post: URL <- ""http://dl.dropbox.com/u/41922443/test.csv" DF1 <- read.table(URL, skip = 1, header = TRUE, sep = ",", fill = TRUE, as.is = TRUE) DF2 <- na.omit(DF1[1:2]) z <- read.zoo(DF2, FUN = chr) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com