Skip to content

initialize all parameters required by Stat and Geom #6409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 18 additions & 4 deletions R/layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,26 @@ layer <- function(geom = NULL, stat = NULL,

# Split up params between aesthetics, geom, and stat
params <- rename_aes(params)
aes_params <- params[intersect(names(params), union(geom$aesthetics(), position$aesthetics()))]
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]
aes_params <- params[
intersect(names(params), union(geom$aesthetics(), position$aesthetics()))
]

# make sure all required parameters have a default value `NULL`
geom_parameters <- geom$parameters(TRUE)
geom_params <- vector("list", length(geom_parameters))
names(geom_params) <- geom_parameters
geom_params[intersect(names(params), geom_parameters)] <- params[
intersect(names(params), geom_parameters)
]
stat_parameters <- stat$parameters(TRUE)
stat_params <- vector("list", length(stat_parameters))
names(stat_params) <- stat_parameters
stat_params[intersect(names(params), stat_parameters)] <- params[
intersect(names(params), stat_parameters)
]

ignore <- c("key_glyph", "name", "layout")
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), position$aesthetics(), ignore)
all <- c(geom_parameters, stat_parameters, geom$aesthetics(), position$aesthetics(), ignore)

# Take care of plain patterns provided as aesthetic
pattern <- vapply(aes_params, is_pattern, logical(1))
Expand Down
Loading