Description Usage Arguments Examples
This function works as a labelling mapper for
ggplot2
, typically used in facet_grid
. All
arguments must be named. Items are mapped as name =>
value
, where name
represents the original levels of
the factor used for facetting.
1 |
... |
A set of named arguments. |
.parse |
boolean; if |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | if (require(ggplot2)) {
df <- data.frame(
x=1:100,
y=rnorm(100),
grp=rep( c("tau+", "tau-"), each=50 ) ## levels are "tau+", "tau-"
)
f <- labeller(
`tau-` = 'tau["-"]',
`tau+` = 'tau["+"]'
)
ggplot(df, aes(x=x, y=y)) +
geom_point() +
facet_grid(". ~ grp", labeller=f)
df$grp2 <- factor(rep( c("beta+", "beta-"), each=50 ))
f <- labeller(
`tau-` = 'tau["-"]',
`tau+` = 'tau["+"]',
`beta+` = 'beta["+"]',
`beta-` = 'beta["-"]'
)
ggplot(df, aes(x=x, y=y)) +
geom_point() +
facet_grid("grp ~ grp2", labeller=f)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.