0

I made a list of dates called newDat that looks like the following:

> newDat
  [1] 4.2.20   4.3.20   4.4.20   4.5.20   4.6.20   4.7.20   4.8.20   4.9.20  
  [9] 4.10.20  4.11.20  4.12.20  4.13.20  4.14.20  4.15.20  4.16.20  4.17.20 
 [17] 4.18.20  4.19.20  4.20.20  4.21.20  4.22.20  4.23.20  4.24.20  4.25.20 
 [25] 4.26.20  4.27.20  4.28.20  4.29.20  4.30.20  5.1.20   5.2.20   5.3.20  
 [33] 5.4.20   5.5.20   5.6.20   5.7.20   5.8.20   5.9.20   5.10.20  5.11.20 
 [41] 5.12.20  5.13.20  5.14.20  5.15.20  5.16.20  5.17.20  5.18.20  5.19.20 
 ...

I subsequently plot my data by using the following code

plot.ts(as.Date(newDat,"%m.%d.%y"), casesDifferenced, type = "l",
        xlab = "Date")

But my x-axis dates are now showing up properly as shown in the image below.

enter image description here

What am I missing here?

325
  • 594
  • 8
  • 21
  • 3
    Try just `plot` rather than `plot.ts` since you aren't actually plotting a true `ts` object here. Also, be sure to share data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can copy/paste into R for testing. Currently we can't run your code to test it. – MrFlick Feb 16 '21 at 19:10
  • I think I solved your problem but I need a minimal. Could you provide the variable `casesDifferenced` too? – Francesco Grossetti Feb 16 '21 at 21:12

1 Answers1

0

Way to fix my problem:

plot(as.Date(newDate,"%m.%d.%y"), casesDifferenced, type = "l", xlab = "Date")
325
  • 594
  • 8
  • 21