please how to insert a carriage return in strip text (ggplot 2.0.9)
I tried :
mf_labeller <- function(var, value){
value <- as.character(value)
if (var=="Nerves") {
value[value=="xv1"] <- c("xv","/r", "1")
value[value=="xv2"] <- c("xv","/r", "2")
}
return(value)
}
facet_grid(..., labeller=mf_labeller)
It returns
Warning in value[value == "xv1"] <- c("xv","/r", "1") : number of items to replace is not a multiple of replacement length
Warning in value[value == "xv2"] <- c("xv","/r", "2") : number of items to replace is not a multiple of replacement length
and only “xv” “xv” on the figure
Thanks for your help
The labeller is telling you that it expecting a string of length 1, and only returning the first element.
Note that I have replaced
/rwith the new line\nI think should be possible to do this with a regex / string split approach. This works (but I’m sure there is better)