Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo/ggplot2Example does not work #131

Closed
travis-leith opened this issue Aug 22, 2024 · 8 comments
Closed

demo/ggplot2Example does not work #131

travis-leith opened this issue Aug 22, 2024 · 8 comments

Comments

@travis-leith
Copy link

At least not with the latest version of ggplot2 (3.5.1)

Even the test in the demo fails

## create `data.table` with `idx` of type `nanotime`:
  idx <- nanotime(1) + 1e9*(1:100)
  dt <- data.table(idx=idx, a=1:100, b=11:110)
  
  ## nanotime on the x-axis:
  ggplot(dt, aes(x=idx, y=b)) +
    geom_line()

fails with

Error: Invalid input: nanotime_trans works with objects of class nanotime only

The failure happens at this check

 if (!inherits(x, "nanotime")) {
        stop("Invalid input: nanotime_trans works with objects of class ",
             "nanotime only", call. = FALSE)
      }
@travis-leith
Copy link
Author

Is it worth making this functionality a core part of the package, and including official tests to prevent regression?

@travis-leith
Copy link
Author

I can get this to work if I remove the type check and also remove anything to do with time zones.

@eddelbuettel
Copy link
Owner

Ack. scales and other things like preferred / default transformation names appear to have changed since this was written as ggplot2 tends to change for better or (here) worse.

This may just need to be withdrawn.

@eddelbuettel
Copy link
Owner

@lsilvest My memory is foggy but we seem to have taken this from your repo at lsilvest/nanotime_ggplot.

Have you by chance revisited 'scales' for ggplot2 for nanotime?

@eddelbuettel
Copy link
Owner

There is a micro-error in the demo file:

modified   demo/ggplot2Example.R
@@ -12,7 +12,7 @@ if (requireNamespace("ggplot2", quietly=TRUE) &&
 
     nanotime_format <- function(format = getOption("nanotimeFormat", default="%Y-%m-%dT%H:%M:%EXS%Ez"),
                                 tz     = getOption("nanotimeTz", default="UTC")) {
-        function(x) format(x, format, tz=tz)
+        function(x) format(x, format, tz)
     }
 

but even with that fixed, and running under Ubuntu 20.04 "focal" as a test (to get an older ggplot2) I get an error:

Error in validate_guide(guide) : Unknown guide

I think it may be best to just quietly retire this demo file. One can plot with nanotime by running as.POSIXct() over the column first.

@travis-leith
Copy link
Author

On one hand I think retiring it would be a shame, but on the other hand, this package isn't really about supporting visualisations from other packages so makes sense to retire.

@lsilvest
Copy link
Collaborator

Yes, I imagine there's been some changes in ggplot2... Before we decide to retire it, I'll take a stab at it and see if we can fix this.

@eddelbuettel
Copy link
Owner

We are coming up to a new CRAN release and I plan to skip shipping the example file there. It needs a bigger update, and maybe these days there are other ggplot2 helper packages for scale manipulation that we can lean on. Another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants