Skip to content

Commit 7d67785

Browse files
committed
Fix na.rm default
1 parent 67da79b commit 7d67785

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 2.0.0.9000
22

3+
* `layer()` now automatically adds a `na.rm` parameter if none is explicitly
4+
supplied.
5+
36
* `layer()` now accepts a function as the data argument. The function will be
47
applied to the data passed to the `ggplot()` function and must return a
58
data.frame (#1527).

R/layer.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ layer <- function(geom = NULL, stat = NULL,
8888
if (is.character(position))
8989
position <- find_subclass("Position", position)
9090

91+
# Special case for na.rm parameter needed by all layers
92+
if (is.null(params$na.rm)) {
93+
params$na.rm <- FALSE
94+
}
95+
9196
# Split up params between aesthetics, geom, and stat
9297
params <- rename_aes(params)
93-
9498
aes_params <- params[intersect(names(params), geom$aesthetics())]
9599
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
96100
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]

0 commit comments

Comments
 (0)