I'm having trouble creating a back-to-back histogram facet grid created with ggplot.
# create data frame with latency values latc_sorted <- data.frame( subject=c(1,1,1,1,1,2,2,2,2,2), grp=c("K_N","K_I","K_N","K_I","K_N","K_I","K_N","K_I","K_N","K_I"), lat=c(22,45,18,55,94,11,67,22,64,44) )
this graph is fine, but if I try the following, I get an error: Error: The casting formula contains variables not found in the molten data: x.sub_k $ subject
hist_K_sub<-qplot(x, geom="histogram", fill="inverted", binwidth=20) + geom_histogram(data=data.frame(x=y), aes(fill="non-inverted", y=-..count..), binwidth= 20) + scale_y_continuous(formatter='my.abs') + coord_flip() + scale_fill_hue("variable")+ facet_grid(x.sub_k$subject ~ .) hist_K_sub
Any ideas why this fails?