Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,8 @@ normalise_label <- function(label) {
if (obj_is_list(label)) {
# Ensure that each element in the list has length 1
label[lengths(label) == 0] <- ""
label <- lapply(label, `[`, 1)
truncate <- !vapply(label, is.call, logical(1)) # Don't mess with call/formula
label[truncate] <- lapply(label[truncate], `[`, 1)
}
if (is.expression(label)) {
# Classed expressions, when converted to lists, retain their class.
Expand Down
11 changes: 11 additions & 0 deletions R/position-.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ Position <- ggproto(
#' A data frame with completed layer data
use_defaults = function(self, data, params = list()) {

if (empty(data)) {
return(data)
}

aes <- self$aesthetics()
defaults <- self$default_aes

Expand All @@ -113,6 +117,13 @@ Position <- ggproto(
return(data)
}

empty_aes <- names(params)[lengths(params) == 0]
if (length(empty_aes) > 0) {
# The Geom$use_defaults method will already warn about this, we just need
# to ignore this here.
params <- params[setdiff(names(params), empty_aes)]
}

new <- compact(lapply(defaults, eval_tidy, data = data))
new[names(params)] <- params
check_aesthetics(new, nrow(data))
Expand Down
2 changes: 1 addition & 1 deletion R/stat-align.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ StatAlign <- ggproto(

finish_layer = function(data, params) {
# Silently remove out-of-bounds padding vertices
var <- flipped_names(params$flipped_aes)$x
var <- flipped_names(params$flipped_aes %||% FALSE)$x
remove <- is.na(data[[var]]) & (data$align_padding %||% FALSE)
vec_slice(data, !remove)
}
Expand Down