0

I have tried everything but I did not manage to succeed. My code so far is the following:

covid_data$day <- as.Date(covid_data$day)
contagion.ts <- ts(covid_data$contagion, frequency = 365)
contagion.hw <- HoltWinters(x=contagion.ts, gamma=FALSE)
plot(contagion.hw)

and I get this plot: enter image description here

Therefore, I would like to customize the xtickers, but it seems impossible and I am honestly giving up. I have read a ton of examples but I cannot figure out why it is not working.

The code I wrote is:

covid_data$day <- as.Date(covid_data$day)
contagion.ts <- ts(covid_data$contagion, frequency = 365)
contagion.hw <- HoltWinters(x=contagion.ts, gamma=FALSE)
plot(contagion.hw, xaxt = "n")
axis(1, at=covid_data$day)

And I obtain this error message: Error in axis(1, at = covid_data$day) : plot.new has not been called yet, which i don't what it means nor how I fix it.

I have documented a lil more and I have discovered I can change directly the xtickers in the plot() function:

covid_data$day <- as.Date(covid_data$day)
contagion.ts <- ts(covid_data$contagion, frequency = 365)
contagion.hw <- HoltWinters(x=contagion.ts, gamma=FALSE)
plot(contagion.hw, xaxp = covid_data$day)

and I get the error message: Error in plot.window(xlim, ylim, log, ...) : the parameter "xaxp" has wrong length

I even tried to change the xtickers with a standard vector c(-100,100,100) but I obtain no xtickers in the plot.

  • `xaxp - A vector of the form c(x1, x2, n) giving the coordinates of the extreme tick marks and the number of intervals between tick-marks` -- so, it shall be in form `xaxp = c(firstDay, lastDay, number_of_days).` It would help if you would like to attach a snapshot of your data and explain, what format of x-axis (labels) you expect. – Grzegorz Sapijaszko Feb 25 '22 at 22:44
  • Please share a reproducible dataset using the `dput` function. Here is how: https://youtu.be/3EID3P1oisg – Shawn Hemelstrand Feb 26 '22 at 01:33

0 Answers0