Skip to content

Commit ab42c2c

Browse files
committed
Improve dontrun usage
1 parent 9d69563 commit ab42c2c

17 files changed

+43
-134
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Suggests:
2929
ggplot2movies,
3030
hexbin,
3131
Hmisc,
32+
lattice,
3233
mapproj,
3334
maps,
3435
maptools,
@@ -38,6 +39,7 @@ Suggests:
3839
testthat (>= 0.11.0),
3940
quantreg,
4041
knitr,
42+
rpart,
4143
rmarkdown,
4244
svglite
4345
Enhances: sp

R/annotation-custom.r

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ NULL
2626
#' base <- ggplot(df, aes(x, y)) +
2727
#' geom_blank() +
2828
#' theme_bw()
29-
#' # Adding a table
30-
#' \dontrun{
31-
#' if (require(gridExtra)) {
32-
#' base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
33-
#' xmin = 3, xmax = 6, ymin = 2, ymax = 8)
34-
#' # full panel
35-
#' base + annotation_custom(grob = roundrectGrob(),
36-
#' xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
37-
#' }
38-
#' }
29+
#'
30+
#' # Full panel annotation
31+
#' base + annotation_custom(
32+
#' grob = grid::roundrectGrob(),
33+
#' xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf
34+
#' )
35+
#'
3936
#' # Inset plot
4037
#' df2 <- data.frame(x = 1 , y = 1)
4138
#' g <- ggplotGrob(ggplot(df2, aes(x, y)) +

R/facet-grid-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
#' theme(strip.background = element_blank())
108108
#'
109109
#' # Margins ----------------------------------------------------------
110-
#' \dontrun{
110+
#' \donttest{
111111
#' # Margins can be specified by logically (all yes or all no) or by specific
112112
#' # variables as (character) variable names
113113
#' mg <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()

R/facet-wrap.r

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ facet_vars.wrap <- function(facet) {
425425
#' # Valid input just gets returns unchanged
426426
#' sanitise_dim(1)
427427
#' sanitise_dim(NULL)
428-
#' \dontrun{
428+
#'
429429
#' # Only the first element of vectors get returned
430430
#' sanitise_dim(10:1)
431431
#' # Non-integer values are coerced to integer
@@ -435,7 +435,6 @@ facet_vars.wrap <- function(facet) {
435435
#' sanitise_dim(NA_integer_)
436436
#' sanitise_dim(0)
437437
#' sanitise_dim("foo")
438-
#' }
439438
#' @noRd
440439
sanitise_dim <- function(n) {
441440
xname <- paste0("`", deparse(substitute(n)), "`")

R/geom-blank.r

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,8 @@
77
#' @inheritParams layer
88
#' @inheritParams geom_point
99
#' @examples
10-
#' ggplot(mtcars, aes(wt, mpg)) + geom_blank()
10+
#' ggplot(mtcars, aes(wt, mpg))
1111
#' # Nothing to see here!
12-
#'
13-
#' # Take the following scatter plot
14-
#' a <- ggplot(mtcars, aes(x = wt, y = mpg), . ~ cyl) + geom_point()
15-
#' # Add to that some lines with geom_abline()
16-
#' df <- data.frame(a = rnorm(10, 25), b = rnorm(10, 0))
17-
#' a + geom_abline(aes(intercept = a, slope = b), data = df)
18-
#' # Suppose you then wanted to remove the geom_point layer
19-
#' # If you just remove geom_point, you will get an error
20-
#' b <- ggplot(mtcars, aes(x = wt, y = mpg))
21-
#' \dontrun{b + geom_abline(aes(intercept = a, slope = b), data = df)}
22-
#' # Switching to geom_blank() gets the desired plot
23-
#' c <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_blank()
24-
#' c + geom_abline(aes(intercept = a, slope = b), data = df)
2512
geom_blank <- function(mapping = NULL, data = NULL,
2613
stat = "identity", position = "identity",
2714
...,

R/geom-smooth.r

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@
5656
#' geom_smooth(span = 0.8) +
5757
#' facet_wrap(~drv)
5858
#'
59-
#' \dontrun{
60-
#' # To fit a logistic regression, you need to coerce the values to
61-
#' # a numeric vector lying between 0 and 1.
59+
#' \donttest{
6260
#' binomial_smooth <- function(...) {
6361
#' geom_smooth(method = "glm", method.args = list(family = "binomial"), ...)
6462
#' }
65-
#'
63+
#' # To fit a logistic regression, you need to coerce the values to
64+
#' # a numeric vector lying between 0 and 1.
6665
#' ggplot(rpart::kyphosis, aes(Age, Kyphosis)) +
6766
#' geom_jitter(height = 0.05) +
6867
#' binomial_smooth()

R/geom-text.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#' p + geom_point() + geom_text(vjust = 0, nudge_y = 0.5)
5252
#' p + geom_point() + geom_text(angle = 45)
5353
#' \dontrun{
54+
#' # Doesn't work on all systems
5455
#' p + geom_text(family = "Times New Roman")
5556
#' }
5657
#'

R/theme.r

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -340,35 +340,6 @@ print.theme <- function(x, ...) utils::str(x)
340340
#' p + mytheme
341341
#'
342342
#' }
343-
#'
344-
#' \dontrun{
345-
#' ## Run this to generate a graph of the element inheritance tree
346-
#' build_element_graph <- function(tree) {
347-
#' require(igraph)
348-
#' require(plyr)
349-
#'
350-
#' inheritdf <- function(name, item) {
351-
#' if (length(item$inherit) == 0)
352-
#' data.frame()
353-
#' else
354-
#' data.frame(child = name, parent = item$inherit)
355-
#' }
356-
#'
357-
#' edges <- plyr::rbind.fill(mapply(inheritdf, names(tree), tree))
358-
#'
359-
#' # Explicitly add vertices (since not all are in edge list)
360-
#' vertices <- data.frame(name = names(tree))
361-
#' graph.data.frame(edges, vertices = vertices)
362-
#' }
363-
#'
364-
#' g <- build_element_graph(ggplot2:::.element_tree)
365-
#' V(g)$label <- V(g)$name
366-
#'
367-
#' set.seed(324)
368-
#' par(mar=c(0,0,0,0)) # Remove unnecessary margins
369-
#' plot(g, layout=layout.fruchterman.reingold, vertex.size=4, vertex.label.dist=.25)
370-
#'
371-
#' }
372343
theme <- function(..., complete = FALSE, validate = TRUE) {
373344
elements <- list(...)
374345

R/translate-qplot-lattice.r

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#' Translating between qplot and lattice
22
#'
3-
#' The major difference between lattice and ggplot2 is that lattice uses a formula based
4-
#' interface. ggplot2 does not because the formula does not generalise well
5-
#' to more complicated situations.
3+
#' The major difference between lattice and ggplot2 is that lattice uses a
4+
#' formula based interface. ggplot2 does not because the formula does not
5+
#' generalise well to more complicated situations.
66
#'
77
#' @name translate_qplot_lattice
88
#' @examples
9-
#' \dontrun{
9+
#' \donttest{
1010
#' library(lattice)
1111
#'
1212
#' if (require("ggplot2movies")) {
@@ -29,13 +29,10 @@
2929
#' qplot(rating, data = movies, geom = "histogram")
3030
#'
3131
#' bwplot(Comedy ~ rating ,data = movies)
32-
#' qplot(factor(Comedy), rating, data = movies, type = "boxplot")
32+
#' qplot(factor(Comedy), rating, data = movies, geom = "boxplot")
3333
#'
3434
#' xyplot(wt ~ mpg, mtcars, type = c("p","smooth"))
3535
#' qplot(mpg, wt, data = mtcars, geom = c("point","smooth"))
36-
#'
37-
#' xyplot(wt ~ mpg, mtcars, type = c("p","r"))
38-
#' qplot(mpg, wt, data = mtcars, geom = c("point","smooth"), method = "lm")
3936
#' }
4037
#'
4138
#' # The capabilities for scale manipulations are similar in both ggplot2 and

cran-comments.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
This is a resubmission, post-review of \dontrun{} usage. Now \dontrun{} is only used in two places: an example that fails on some platforms, and an ggsave() examples which save files on disk.
2+
3+
---------------------------------
4+
15
## Test environments
26
* OS X, R 3.2.3
37
* Ubuntu 14.04, R 3.2.3

man/annotation_custom.Rd

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/facet_grid.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_blank.Rd

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_smooth.Rd

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_text.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/theme.Rd

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/translate_qplot_lattice.Rd

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)