I have a problem with R ggplot2.
Im getting this error:
Error in scale_labels.continuous(scale, breaks) :
Breaks and labels are different lengths
even though im sure that breaks and labels are the same length.
is there anyway to debug the plots (i.e check the plot variable for breaks and labels to check where is the error)
the code im using is:
dataf$pval.d <- cut(dataf$pvalue, breaks=c(min(dataf$X),0.05,Inf),
labels=c("min","0.05"), right = FALSE)
pl <-ggplot(dataf) +
geom_tile(aes(fill=C,A,B)) +
stat_contour(breaks = c(min(dataf$X),0.05),
aes(x=A,y=B,z=pvalue,colour = ..level..)) +
scale_colour_gradient2(low="black",mid="black",high="green",
labels=paste(levels(dataf$pval.d),table(dataf$pval.d)),
name="\n P-value \n")
a sample of the data frame dataf
is something like that:
A B C pval
1 8 4 0.6714801 0.3138729
2 9 9 0.6373763 0.1402027
3 5 6 0.6695279 0.3426810
4 10 7 0.6338043 0.1722161
5 2 3 0.6692842 0.3301052
6 1 1 0.6728664 0.5777641
7 6 2 0.6608868 0.2637952
8 3 10 0.6721009 0.6584530
9 7 8 0.6338043 0.7839811
10 4 5 0.6728818 0.5045481
the output of:
> paste(levels(dataf$pval.d),table(dataf$pval.d))
[1] "min 0" "0.05 10"
as you can see, the labels and breaks are of the same length, but maybe im making something wrong which im not aware about?