I\'ve a data.frame that looks like this:
> foo
class type (0,10] (10,20] (20,30] (30,40]
1 A 0.6
You will have to do the data duplication due to ggplot
's philosophy: Each item in the plot represents exactly one data point. So if you want to have the NA
data in two facets, you need to create two data points for each original data item.
If you want to avoid explicitly creating temporary data just for plotting, you can create a function that will do the data duplication for you. Something along the following lines:
distribute.na.type <- function(dat) {
rbind(
transform(subset(dat, type %in% c(1, NA)), type=1),
transform(subset(dat, type %in% c(2, NA)), type=2)
)
}
The above example is untested and not very generic, but with a little bit of luck it'll just work. Use it like this: distribute.na.type(melt(...))
.