When I try to use ggplot together with data.table I discovered an odd behaviour which seems to be a bug.
Depending on the order of the rows I set in my data.table (using setkey(data,V1,V2..)), facet_grids differ completely.
Here is an example of the working facet_grid:
setkey(dat.rel,FINISH_TIME_BUFFER) #Set Order of Rows according t FINISH_TIME_BUFFER
ggplot(dat.rel)+ #Make Plot
aes(x=dat.rel$INdex,y=dat.rel$GWorkerMissing)+
scale_colour_gradientn(colours=rainbow(10),trans="log",breaks=c(1,100,500,10000))+
geom_point(aes(color=dat.rel$MAX_RUNTIME_IN_SECONDS),size=10,alpha=0.7)+
facet_grid( ~ dat.rel$FINISH_TIME_BUFFER)+
geom_text(aes(label=dat.rel$FINISH_TIME_BUFFER),size=4)
That is the result:
If I now substitute the first line with
setkey(dat.rel,INdex)
which orders the data.table by an Index, the result is the following:
As you can see on the geom_text on every point, the FINISH_TIME_BUFFER is not assigned correctly to the respective grid.
It seems that there is a Bug in ggplot, but to be sure that it's not my fault I give it a try here.
Just remove all dat.rel$ inside the plot configuration makes the facet_grids work like desired, indipendently from the row order.