base plot function produce distorted chart

Hello R community,

Context: the base plot function outputs a distorted chart.
Goal: Need help to get the correct chart (how it should be) when plot function is used

To reproduce this issue:

Load packages:

library(incidence)
library(outbreaks)

Using the dataset in the outbreaks package:

dat <- ebola_sim$linelist$date_of_onset
class(dat)

i <- incidence(dat)

plot(i)

The plot looks like this:

However, the plot should look like this according to the outbreak package help file:

Thank you so much for your help.

I can't reproduce your issue, but you could also make the plot manually

library(incidence)
library(outbreaks)

dat <- ebola_sim$linelist$date_of_onset
class(dat)
#> [1] "Date"

i <- incidence(dat)

plot(i)


# You can also do it manually

library(ggplot2)

dates <- data.frame(date = as.Date(i$dates),
                    count = i$counts)
ggplot(dates, aes(x = date, y = count)) +
    geom_col() +
    labs(x = "",
         y = "Daily incidence")

Created on 2020-03-29 by the reprex package (v0.3.0)

I did the hard way at the end - uninstalled and then installed R and Rstudio. Now it works!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.