I'm working with a set of data, each containing a list of 3 dates related to when one of three sequential actions is taken:
action.1 <- sample(seq(as.Date('2010-01-01'), as.Date('2010-02-01'), by="day"), 200, replace=TRUE)
action.2 <- action.1 + sample(seq(0,10,by=1), 200, replace=TRUE)
action.3 <- action.2 + sample(seq(0,40,by=1), 200, replace=TRUE)
action.1
action.1
action.2
rankn <- rank(action.1, ties.method = "first")
attach(mtcars)
layout(matrix(c(1,2), 2, 1, byrow = TRUE))
d1 = min(action.1, action.2, action.3)
d2 = max(action.1, action.2, action.3)
plot(table(action.1))
plot(action.1, rankn, col="red3", xlim=c(d1, d2))
points(action.2, rankn, col='green3')
points(action.3, rankn, col='blue3')
plot(table(action.1)), xlim=c(d1,d2))
Find the common part between lists, which should be max(min(list_1), min(list_2),...)
to min(max(list_1), max(list_2),...)
.
So the problem is with your d2
: d2 = 2010-03-15
, instead you should assign it with:
d2 <- min(max(action.1), max(action.2), max(action.3))
Then, d2 = 2010-02-01
, also with d1
I think, assign it with d1 <- max(min(action.1), min(action.2), min(action.3))
. If this is your expected result(ignore the Chinese format):
EDIT:
I prefer to use par(mfrow = c(2,1))
to manage the plot layout. So:
par(mfrow = c(2,1))
d1 <- max(min(action.1), min(action.2), min(action.3))
d2 <- min(max(action.1), max(action.2), max(action.3))
plot(table(action.1))
plot(action.1, rankn, col="red3", xlim=c(d1, d2))
points(action.2, rankn, col='green3')
points(action.3, rankn, col='blue3')