[R] logical test not functioning correctly on zoo series...what the hell?

William Dunlap wdunlap at tibco.com
Wed Mar 14 21:17:36 CET 2012


Here is an example of the start of a self-contained way to reproduce your problem:
> library(chron) 
> library(zoo)
> rawData <- read.zoo("http://r.789695.n4.nabble.com/file/n4472408/dataout_2471_843.csv",  header = TRUE,  
+       FUN = as.chron, format = "%m/%d/%Y %H:%M", index.column = 2,
+       sep = ",", aggregate = function(x) tail(x, 1))
...

str() shows that the data is a 2-column character matrix:
> str(rawData)
'zoo' series from (02/11/12 12:45:00) to (02/22/12 08:30:00)
  Data: chr [1:1040, 1:2] "MCAS-B-2471        " "MCAS-B-2471        " "MCAS-B-2471        " ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:1040] "1" "2" "3" "4" ...
  ..$ : chr [1:2] "Meter.ID" "KW.ch..1..set.0."
  Index: Classes 'chron', 'dates', 'times'  atomic [1:1040] -715103 -715103 -715103 -715103 -715103 ...
  ..- attr(*, "format")= Named chr [1:2] "m/d/y" "h:m:s"
  .. ..- attr(*, "names")= chr [1:2] "dates" "times"
  ..- attr(*, "origin")= Named num [1:3] 1 1 1970
  .. ..- attr(*, "names")= chr [1:3] "month" "day" "year"

You need to figure out how to import the data as a character column and a numeric column
if you want the comparison with 0 to work.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of knavero
> Sent: Wednesday, March 14, 2012 9:43 AM
> To: r-help at r-project.org
> Subject: Re: [R] logical test not functioning correctly on zoo series...what the hell?
> 
> attached http://r.789695.n4.nabble.com/file/n4472408/dataout_2471_843.csv
> dataout_2471_843.csv
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/logical-test-not-
> functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472408.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list