I have a dataset where I have a binary value on a timeline. So for example:
Date, Event
January-29-2014, 1
January-29-2014, 0
January-29-2014, 1
January-29-2014, 1
January-30-2014, 0
I would like to plot the 1,0 on a timeline(by Date) and in color (red bar = 1,blue bar = 0) How can I achieve this ? How do you call this ? e.g. binary timeline plotting :)
Sorry and thanks for your help.
Is think this is what you want. Using fake data:
n = 100
x = seq(n)
y = sample(0:1, n, replace=TRUE)
DF = data.frame(Date=x, Event=y)
ones = rep(1, nrow(DF))
colors = c("blue", "red")
plot(DF$Date, ones, type="h", col=colors[DF$Event +1],
ylim=c(0,1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With