Reputation: 1263
Novice R question: given a number of observations over a range of dates, e.g.,
obs <- as.Date(c("2001-08-02","2001-08-02", "2001-08-02","2001-08-03",
"2001-08-04", "2001-08-04", "2001-08-07", "2001-08-07"))
I can plot the frequencies of observations over time with
plot(table(obs))
However, how can I generate a table plot from obs
that includes all intermediate missing dates (i.e., "2001-08-05", "2001-08-06") showing zero frequency?
Upvotes: 1
Views: 60
Reputation: 1544
You should probably use the hist
function instead, it covers cases like these.
hist(obs, breaks='day', format = "%d %b", freq=TRUE)
Upvotes: 2
Reputation: 1966
Try this:
obs <- c(obs, seq(min(obs), max(obs), 1))
plot(table(obs) - 1)
Upvotes: 2