-
Notifications
You must be signed in to change notification settings - Fork 13
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
problems with plotting POSIXt incidence + fit objects #99
Comments
Wait.... I think I know why the data are being shifted... library("incidence")
days <- 1:14
dat_cases <- round(exp(.2*(days)))
dat_dates_Date <- rep(as.Date(Sys.Date() + days), dat_cases)
dat_dates_POSIXct <- as.POSIXct(dat_dates_Date)
iD <- incidence(dat_dates_Date)
iP <- incidence(dat_dates_POSIXct)
as.data.frame(iP, long = TRUE)$dates + (86400/2)
#> [1] "2019-01-09 21:00:00 KST" "2019-01-10 21:00:00 KST"
#> [3] "2019-01-11 21:00:00 KST" "2019-01-12 21:00:00 KST"
#> [5] "2019-01-13 21:00:00 KST" "2019-01-14 21:00:00 KST"
#> [7] "2019-01-15 21:00:00 KST" "2019-01-16 21:00:00 KST"
#> [9] "2019-01-17 21:00:00 KST" "2019-01-18 21:00:00 KST"
#> [11] "2019-01-19 21:00:00 KST" "2019-01-20 21:00:00 KST"
#> [13] "2019-01-21 21:00:00 KST" "2019-01-22 21:00:00 KST"
as.data.frame(iD, long = TRUE)$dates + (1/2)
#> [1] "2019-01-09" "2019-01-10" "2019-01-11" "2019-01-12" "2019-01-13"
#> [6] "2019-01-14" "2019-01-15" "2019-01-16" "2019-01-17" "2019-01-18"
#> [11] "2019-01-19" "2019-01-20" "2019-01-21" "2019-01-22" Created on 2019-01-08 by the reprex package (v0.2.1) |
The data are being shifted because I'm in a time zone that's 9 hours ahead and ggplot2 is considering that when plotting. |
I'm going to stop here today and pick this up tomorrow |
Damn. Locals are gonna be horrible on this one. |
There should be a way to deal with it. |
This might be the solution: |
This will fix #99 - ggplot2 timezone set to UTC for POSIXt plotting - match the data type in `add_incidence_fit()` of the predictors and the incoming ggplot2 date column. This is necessary because of the change in #92 where fit data were changed to Date to give more sensible coefficients. - update POSIXt test plot that was accidentally saved from the KST time zone
The solution, it turns out, was to use the The solution to the mis-match of classes was a bit trickier. I thought I was able to do a simple Line 341 in d9bc202
And now it works :) library("incidence")
days <- 1:14
dat_cases <- round(exp(.2*(days)))
dat_dates_Date <- rep(as.Date(Sys.Date() + days), dat_cases)
dat_dates_POSIXct <- as.POSIXct(dat_dates_Date)
iD <- incidence(dat_dates_Date)
iP <- incidence(dat_dates_POSIXct)
plot(iD, fit = fit(iD)) plot(iP, fit = fit(iP)) Created on 2019-01-09 by the reprex package (v0.2.1) |
Wikid! :) |
This was going to be a separate issue for an error brought up due to changes made in #92, but I realize now that something has been screwed up in general (and I thought I tested it 😞).
Basically, the POSIXt plotting is shifted forward half a day (as opposed to having the left-hand side of the bin representing the day. Moreover, because the fit is now converted to
Date
, it no longer can be plotted with the POSIXt data.Here's an example:
plot(iP)
plot(fit(iP))
Created on 2019-01-08 by the reprex package (v0.2.1)
The text was updated successfully, but these errors were encountered: