Forum: open-discussion


RE: Bug in ggplot2.zoo.R [ Reply ] By: Joshua Ulrich on 2018-04-08 16:12 | [forum:45829] |
I completely agree with (3), and strongly emphasize that it is very bad practice for a package to include methods for classes it does not own. |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Achim Zeileis on 2018-04-06 21:19 | [forum:45828] |
OK, good, thanks for the feedback. To install "zoo" from R-Forge you can do: install.packages("zoo", repos="http://R-Forge.R-project.org") The next CRAN release is not scheduled yet. |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Meet Dave on 2018-04-06 16:28 | [forum:45827] |
Thanks. autoplot.zoo works like a charm. Saved me the effort of compulsorily downgrading zoo everytime I run the code in some new machine. Also, when can I expect new build of 'zoo' on CRAN? Regarding ggfortify, I will raise the issue on github, Thanks a lot once again. |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Achim Zeileis on 2018-04-06 14:54 | [forum:45824] |
OK, thanks. (1) I would recommend _not_ using ggfortify:::autoplot.xts (or ggfortify:::autoplot.zooreg) but to use zoo::autoplot.zoo instead. It calls the fortify() method correctly and returns the ggplot2 objects so that you can add layers "as usual" in ggplot2. (2) I have modified zoo::fortify.zoo so that only the arguments in ... are passed on to data.frame() that correspond to named arguments. Everything else is simply dropped. (3) What ggfortify does, looks fishy to me (without digging much into the details). I would recommend that you notify the ggfortify authors and raise the issue. |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Meet Dave on 2018-04-06 14:22 | [forum:45823] |
https://github.com/sinhrks/ggfortify/blob/v0.4.3/R/base_fortify_ts.R You can find autoplot.xts in ggfortify package. As you can see in the file above on line 271, autoplot.ts is assigned to autoplot.xts |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Achim Zeileis on 2018-04-06 13:10 | [forum:45822] |
Where is this autoplot.xts coming from? I don't see it in the xts package, neither on CRAN nor GitHub. This is relevant because I want to understand who uses these arguments and what they intend with it. Otherwise I would just ignore these arguments in fortify.zoo(). |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Meet Dave on 2018-04-06 04:29 | [forum:45821] |
Thanks for responding. I have recreated the issue that I am facing R> library("zoo") R> library("ggplot2") R> z <- zoo(matrix(1:10, ncol = 2), Sys.Date() - 5:1) R> colnames(z) <- c("A", "B") R> fortify(z) Index A B 1 2018-03-31 1 6 2 2018-04-01 2 7 3 2018-04-02 3 8 4 2018-04-03 4 9 5 2018-04-04 5 10 R> ggplot2::fortify(z, scale = T,is.date = T, index.name = "Index") Index A B NA NA NA 1 2018-04-01 TRUE TRUE Index 1 6 2 2018-04-02 TRUE TRUE Index 2 7 3 2018-04-03 TRUE TRUE Index 3 8 4 2018-04-04 TRUE TRUE Index 4 9 5 2018-04-05 TRUE TRUE Index 5 10 The last command is being called by autoplot.xts which I have no control over. As you can see, the column names in the output are wrong. Also it has made columns for boolean parameters passed. Hope this will help |
RE: Bug in ggplot2.zoo.R [ Reply ] By: Achim Zeileis on 2018-04-05 21:52 | [forum:45819] |
Thanks for raising this issue. However, from the information you supplied I was not able to reconstruct what exactly the problem is. Could you provide a reproducible example? And the ... are passed to data.frame() so that you can set certain arguments, e.g., row.names: R> library("zoo") R> library("ggplot2") R> z <- zoo(matrix(1:10, ncol = 2), Sys.Date() - 5:1) R> colnames(z) <- c("A", "B") R> fortify(z) Index A B 1 2018-03-31 1 6 2 2018-04-01 2 7 3 2018-04-02 3 8 4 2018-04-03 4 9 5 2018-04-04 5 10 R> fortify(z, row.names = time(z)) Index A B 2018-03-31 2018-03-31 1 6 2018-04-01 2018-04-01 2 7 2018-04-02 2018-04-02 3 8 2018-04-03 2018-04-03 4 9 2018-04-04 2018-04-04 5 10 |
Bug in ggplot2.zoo.R [ Reply ] By: Meet Dave on 2018-04-05 16:12 | [forum:45818] |
Function :- fortify.zoo } else { df <- cbind(data.frame(index(model), ...), coredata(model)) names(df) <- c(nm[1L], lab) } Here df cbinds variables passed as ellipsis. But the second line gives only two colnames which are also not in proper order. This is incorrect id feel. Moreover, previous version of this function used to return an xts object converted to dataframe. In the latest version, it return dataframe with unncessary boolean parameters such as is.Date=T attached to it which are passed as ellipsis. For e.g autoplot.xts passes variables such as is.scale, is.Date, etc. No matter what you pass in this variable i.e True/False/NULL, the returned dataframe from the function fortify.zoo will have this varibales cbinded to it. |