Include the \ t character in facet strip text using a custom label

UPDATE:. After posting the problem in ggplot2 GitHub, the problem is that R does not allow tab characters in graphics devices.


I am trying to mark the edges of my plot using my own label. The text for my shortcuts contains both \ t and \ n. \ N characters are displayed correctly, but \ t creates squares.

tabLabeller <- function(variable, value) { return(paste0(as.character(value), 'Tab\tneeded Newline\nneeded')) } ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point() + facet_grid(~carb, labeller = tabLabeller) 

Here's the chart:

enter image description here

Session Information:

 > sessionInfo() R version 3.2.0 (2015-04-16) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.9.5 (Mavericks) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_1.0.1 loaded via a namespace (and not attached): [1] labeling_0.3 MASS_7.3-40 colorspace_1.2-6 scales_0.2.4 magrittr_1.5 plyr_1.8.2 [7] tools_3.2.0 gtable_0.1.2 reshape2_1.4.1 Rcpp_0.11.5 stringi_0.4-1 grid_3.2.0 [13] stringr_1.0.0 digest_0.6.8 proto_0.3-10 munsell_0.4.2 
+2
r ggplot2
source share

No one has answered this question yet.

See similar questions:

7
Expression in face labels ggplot2

or similar:

205
How to change facet labels?
4
EBImage Function Names
4
Cross references not working in rmarkdown diagram view
4
Knitr gives different results than RStudio
3
R package sqldf does not load tcltk and does not return a warning. How to solve it?
2
SVM plot linear model prepared by a carriage package in R
one
Is it possible to split the tufte_html format into chapters in bookdown / rmarkdown?
one
Brilliant R: outputting results to a scatter plot along with existing csv data
0
How to fix "Error: object" as_tibble is not exported by "namespace: dplyr" ERROR: deferred loading failed for package "EMPTY" in R
0
Victim from R using rJava on OSX

All Articles