sinhrks / ggfortify

Define fortify and autoplot functions to allow ggplot2 to handle some popular R packages.
Other
525 stars 65 forks source link

xts example failed on Travis build #184

Open terrytangyuan opened 6 years ago

terrytangyuan commented 6 years ago

The following code:

require(xts)
require(ggfortify)
autoplot(as.xts(AirPassengers), ts.colour = 'green')

gives the error on master branch (no recent code changes):

Error in data.frame(index(model), ...) : 
  arguments imply differing number of rows: 144, 1, 0

Looks like some dependency changes. @sinhrks Could you look into it when you get a chance?

terrytangyuan commented 6 years ago

@sinhrks I've commented out a few tests related to xts and timeSeries with a comment ## TODO: CRAN temporary fix in test-ts.R and test-base_ts.R. I also pushed a couple of fixes pointed out by CMD check and resubmitted to CRAN. Please help look into this issue when you get a chance. Thanks!

test-ts.R:

test_that('autoplot works for xts', {
  library(vars)
  data(Canada)

  library(xts)
  p <- autoplot(as.xts(AirPassengers), ts.colour = 'green')
  expect_equal(length(p$layers), 1)
  expect_true(is(p$layers[[1]]$geom, 'GeomLine'))

  p <- autoplot(as.xts(Canada), ts.colour = 'green')
  expect_equal(length(p$layers), 1)
  expect_true(is(p$layers[[1]]$geom, 'GeomLine'))
})

test-base_ts.R:

  p <- autoplot(xts::as.xts(UKgas))
  expect_true(is(p, 'ggplot'))

  p <- autoplot(xts::as.xts(Canada))
  expect_true(is(p, 'ggplot'))

  p <- autoplot(timeSeries::as.timeSeries(Canada))
  expect_true(is(p, 'ggplot'))