Skip to content

Commit 687ba6e

Browse files
committed
Avoid more non-standard evaluation
1 parent 7d0d536 commit 687ba6e

File tree

7 files changed

+24
-11
lines changed

7 files changed

+24
-11
lines changed

R/facet-layout.r

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ layout_grid <- function(data, rows = NULL, cols = NULL, margins = NULL, drop = T
3232
cols <- if (is.null(names(cols))) 1L else id(base[names(cols)], drop = TRUE)
3333

3434
panels <- data.frame(PANEL = panel, ROW = rows, COL = cols, base)
35-
arrange(panels, PANEL)
35+
panels <- panels[order(panels$PANEL), ]
36+
rownames(panels) <- NULL
37+
panels
3638
}
3739

3840
# Layout out panels in a 1d ribbon.
@@ -59,7 +61,9 @@ layout_wrap <- function(data, vars = NULL, nrow = NULL, ncol = NULL, as.table =
5961
layout$COL <- as.integer((id - 1L) %% dims[2] + 1L)
6062

6163
panels <- cbind(layout, unrowname(base))
62-
panels[order(panels$PANEL), ]
64+
panels <- panels[order(panels$PANEL), ]
65+
rownames(panels) <- NULL
66+
panels
6367
}
6468

6569
layout_null <- function(data) {

R/facet-locate.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ locate_grid <- function(data, panels, rows = NULL, cols = NULL, margins = FALSE)
4747
data$PANEL <- panels$PANEL[match(keys$x, keys$y)]
4848
}
4949

50-
arrange(data, PANEL)
50+
data[order(data$PANEL), , drop = FALSE]
5151
}
5252

5353
locate_wrap <- function(data, panels, vars) {

R/guide-legend.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ guide_gengrob.legend <- function(guide, theme) {
297297

298298
# default setting
299299
label.position <- guide$label.position %||% "right"
300-
if (!label.position %in% c("top", "bottom", "left", "right")) stop("label position \"", label.position, "\" is invalid")
300+
if (!label.position %in% c("top", "bottom", "left", "right"))
301+
stop("label position \"", label.position, "\" is invalid")
301302

302303
nbreak <- nrow(guide$key)
303304

R/plot-render.r

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ ggplot_gtable <- function(data) {
3232

3333
# helper function return the position of panels in plot_table
3434
find_panel <- function(table) {
35-
summarise(subset(table$layout, grepl("^panel", name)),
36-
t = min(t), r = max(r), b = max(b), l = min(l))
35+
layout <- table$layout
36+
panels <- layout[grepl("^panel", layout$name), , drop = FALSE]
37+
38+
data.frame(
39+
t = min(panels$t),
40+
r = max(panels$r),
41+
b = max(panels$b),
42+
l = min(panels$l)
43+
)
3744
}
3845

3946
# List by layer, list by panel
@@ -137,7 +144,8 @@ ggplot_gtable <- function(data) {
137144
title_height <- grobHeight(title) +
138145
if (is.null(plot$labels$title)) unit(0, "lines") else unit(0.5, "lines")
139146

140-
pans <- subset(plot_table$layout, grepl("^panel", name))
147+
pans <- plot_table$layout[grepl("^panel", plot_table$layout$name), ,
148+
drop = FALSE]
141149

142150
plot_table <- gtable_add_rows(plot_table, title_height, pos = 0)
143151
plot_table <- gtable_add_grob(plot_table, title, name = "title",

R/stat-summary.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ StatSummary <- proto(Stat, {
157157
# @param other arguments passed on to summary function
158158
# @keyword internal
159159
summarise_by_x <- function(data, summary, ...) {
160-
summary <- ddply(data, .(group, x), summary, ...)
161-
unique <- ddply(data, .(group, x), uniquecols)
160+
summary <- ddply(data, c("group", "x"), summary, ...)
161+
unique <- ddply(data, c("group", "x"), uniquecols)
162162
unique$y <- NULL
163163

164164
merge(summary, unique, by = c("x", "group"))

R/stat-vline.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ compute_intercept <- function(data, intercept, var = "x") {
126126
data[[ivar]] <- f(data[[var]])
127127
data
128128
}
129-
data <- ddply(data, .(group), trans)
129+
data <- ddply(data, "group", trans)
130130
} else {
131131
stop("Invalid intercept type: should be a numeric vector, a function",
132132
", or a name of a function", call. = FALSE)

R/utilities-table.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ compute_grob_dimensions <- function(grob_layout, dims) {
1414
return(unit(1, "null"))
1515
}
1616

17-
grob_layout <- subset(grob_layout, type %in% names(dims))
17+
grob_layout <- grob_layout[grob_layout$type %in% names(dims), , drop = FALSE]
1818

1919
dims <- unique(Map(function(type, pos) {
2020
type_width <- dims[[type]]

0 commit comments

Comments
 (0)