@@ -103,26 +103,18 @@ label_wrap_gen <- function(width = 25) {
103103# ' \code{\link{facet_grid}} for the argument \code{labeller}.
104104# ' @export
105105# ' @examples
106- # '
107- # ' data(mpg)
108- # '
106+ # ' \donttest{
109107# ' p1 <- ggplot(mpg, aes(cty, hwy)) + geom_point()
110- # '
111- # '
112108# ' p1 + facet_grid(cyl ~ class, labeller=label_both)
113- # '
114109# ' p1 + facet_grid(cyl ~ class, labeller=labeller(cyl=label_both))
115110# '
116111# ' ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() +
117112# ' facet_grid(vs + am ~ gear, margins=TRUE,
118113# ' labeller=labeller(vs=label_both, am=label_both))
119114# '
120- # '
121- # '
122- # ' data(msleep)
123115# ' capitalize <- function(string) {
124116# ' substr(string, 1, 1) <- toupper(substr(string, 1, 1))
125- # ' string
117+ # ' string
126118# ' }
127119# ' conservation_status <- c('cd'='Conservation Dependent',
128120# ' 'en'='Endangered',
@@ -132,22 +124,22 @@ label_wrap_gen <- function(width = 25) {
132124# ' 'domesticated'='Domesticated')
133125# ' ## Source: http://en.wikipedia.org/wiki/Wikipedia:Conservation_status
134126# '
135- # ' p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point() +
136- # ' p2 + facet_grid(vore ~ conservation, labeller= labeller(vore= capitalize))
127+ # ' p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point()
128+ # ' p2 + facet_grid(vore ~ conservation, labeller = labeller(vore = capitalize))
137129# '
138130# ' p2 + facet_grid(vore ~ conservation,
139- # ' labeller=labeller(vore= capitalize, conservation= conservation_status ))
131+ # ' labeller=labeller(vore = capitalize, conservation = conservation_status ))
140132# '
141133# ' # We could of course have renamed the levels;
142134# ' # then we can apply another nifty function:
143- # ' library(plyr)
144- # ' msleep$conservation2 <- revalue(msleep$conservation, conservation_status)
145- # '
146- # ' p2 + facet_grid(vore ~ conservation2, labeller=labeller(vore=capitalize))
147- # '
148- # ' p2 + facet_grid(vore ~ conservation2,
149- # ' labeller=labeller(conservation2=label_wrap_gen(10) ))
135+ # ' msleep$conservation2 <- plyr::revalue(msleep$conservation, conservation_status)
150136# '
137+ # ' p2 %+% msleep +
138+ # ' facet_grid(vore ~ conservation2, labeller = labeller(vore = capitalize))
139+ # ' p2 %+% msleep +
140+ # ' facet_grid(vore ~ conservation2, labeller = labeller(conservation2 =
141+ # ' label_wrap_gen(10)))
142+ # ' }
151143labeller <- function (... , keep.as.numeric = FALSE ) {
152144 args <- list (... )
153145
0 commit comments