[R] trouble with starting date in sts and disProg objects in the surveillance package
Christopher W Ryan
cryan at binghamton.edu
Tue Dec 27 19:19:12 CET 2016
I create a data frame, then, using package surveillance version 1.3, I
convert it to a surveillance time series (sts) object and then to a disProg
object. But in the plot of the disProg object, the dates seem to be
mislabelled?
Grateful for any advice.
--Chris Ryan
Broome County Health Department
Binghamton, NY
Below is MWE to reproduce the behavior
library(surveillance)
ll <- data.frame(onset = sample(1:200, size = 400, replace = TRUE))
## let the dates begin in mid-September 2012
ll$onset.date <- as.Date("2012-09-15") + ll$onset
dd.sts <- linelist2sts(ll, dateCol="onset.date", aggregate.by="1 week")
## the below command produces a plot where the horizontal (time) axis
begins around mid-September 2012, as expected
plot(dd.sts)
## now convert the sts object to a disProg object
dd.dp <- sts2disProg(dd.sts)
## the below commands shows the start date of the disProg object seems as
expected
str(dd.dp)
dd.dp$start
## But when I plot the disProg object, the horizontal axis is labelled
differently.
## It seems to begin back in 2011 or before
plot(dd.dp)
## here is my sessionInfo
R version 3.3.1 (2016-06-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252
LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] surveillance_1.13.0 polyCub_0.5-2 xtable_1.8-2
sp_1.2-4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 lattice_0.20-34 deldir_0.1-12 MASS_7.3-45
grid_3.3.1 nlme_3.1-128
[7] tensor_1.5 spatstat_1.48-0 goftest_1.0-3 rpart_4.1-10
Matrix_1.2-7.1 tools_3.3.1
[13] polyclip_1.5-6 abind_1.4-5 mgcv_1.8-16
[[alternative HTML version deleted]]
More information about the R-help
mailing list