I have a data frame with two variables. The first variable are dates. The second variable is logical and specifies whether some statement is true or false for that day (e.g. "On that day it rained.").
I'd like to plot that data so that a curve dips more or less far from 1 (for TRUE) towards 0 (for FALSE), depending on the density of FALSE values in a time span. That is, the more FALSE values close to each other, the deeper the dip. Sort of like this:
Sample data:
dat <- read.table(textConnection("
Var1 Var2
2019-01-01 TRUE
2019-01-02 TRUE
2019-01-03 TRUE
2019-01-04 TRUE
2019-01-05 TRUE
2019-01-06 TRUE
2019-01-07 TRUE
2019-01-08 TRUE
2019-01-09 FALSE
2019-01-10 TRUE
2019-01-11 TRUE
2019-01-12 TRUE
2019-01-13 TRUE
2019-01-14 TRUE
2019-01-15 TRUE
2019-01-16 TRUE
2019-01-17 FALSE
2019-01-18 TRUE
2019-01-19 FALSE
2019-01-20 TRUE
2019-01-21 FALSE
2019-01-22 TRUE
2019-01-23 TRUE
2019-01-24 TRUE
2019-01-25 TRUE
2019-01-26 TRUE
2019-01-27 TRUE
2019-01-28 TRUE
2019-01-29 TRUE
2019-01-30 TRUE
2019-01-31 TRUE
2019-02-01 TRUE
2019-02-02 FALSE
2019-02-03 TRUE
2019-02-04 FALSE
2019-02-05 FALSE
2019-02-06 FALSE
2019-02-07 TRUE
2019-02-08 FALSE
2019-02-09 FALSE
2019-02-10 TRUE
2019-02-11 TRUE
2019-02-12 TRUE
2019-02-13 TRUE
2019-02-14 TRUE
2019-02-15 TRUE
2019-02-16 FALSE
2019-02-17 FALSE
2019-02-18 FALSE
2019-02-19 FALSE
2019-02-20 TRUE
2019-02-21 FALSE
2019-02-22 TRUE
2019-02-23 FALSE
2019-02-24 FALSE
2019-02-25 TRUE
2019-02-26 TRUE
2019-02-27 FALSE
2019-02-28 TRUE
2019-03-01 TRUE
"), header = TRUE, colClasses=c("Date", "logical"))
plot(dat)