Skip to content

Commit 71cb174

Browse files
authored
validate mapping before data in layer(). closes #2862 (#2871)
1 parent 519a55d commit 71cb174

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/layer.r

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ layer <- function(geom = NULL, stat = NULL,
8181
show.legend <- FALSE
8282
}
8383

84-
data <- fortify(data)
85-
84+
# we validate mapping before data because in geoms and stats
85+
# the mapping is listed before the data argument; this causes
86+
# less confusing error messages when layers are accidentally
87+
# piped into each other
8688
if (!is.null(mapping)) {
8789
mapping <- validate_mapping(mapping)
8890
}
8991

92+
data <- fortify(data)
93+
9094
geom <- check_subclass(geom, "Geom", env = parent.frame())
9195
stat <- check_subclass(stat, "Stat", env = parent.frame())
9296
position <- check_subclass(position, "Position", env = parent.frame())

0 commit comments

Comments
 (0)