Permalink
Browse files

Supply all arguments to match.arg

Do not rely on argument evaluation
  • Loading branch information...
1 parent bcd9961 commit a658737ee646ca3dfc256c52f69d9ea49cc5c0a0 @jiho jiho committed with wch Jun 14, 2012
Showing with 4 additions and 4 deletions.
  1. +1 −1 R/geom-violin.r
  2. +3 −3 R/stat-ydensity.r
View
@@ -66,7 +66,7 @@
#' group = round_any(year, 10, floor))
#' }
geom_violin <- function (mapping = NULL, data = NULL, stat = "ydensity", position = "dodge",
-trim = TRUE, scale = c("area", "count", "width"), ...) {
+trim = TRUE, scale = "area", ...) {
GeomViolin$new(mapping = mapping, data = data, stat = stat,
position = position, trim = trim, scale = scale, ...)
}
View
@@ -28,7 +28,7 @@
#' # See geom_violin for examples
#' # Also see stat_density for similar examples with data along x axis
stat_ydensity <- function (mapping = NULL, data = NULL, geom = "violin", position = "dodge",
-adjust = 1, kernel = "gaussian", trim = TRUE, scale = c("area", "count", "width"), na.rm = FALSE, ...) {
+adjust = 1, kernel = "gaussian", trim = TRUE, scale = "area", na.rm = FALSE, ...) {
StatYdensity$new(mapping = mapping, data = data, geom = geom, position = position,
adjust = adjust, kernel = kernel, trim = trim, scale = scale,
na.rm = na.rm, ...)
@@ -38,12 +38,12 @@ StatYdensity <- proto(Stat, {
objname <- "ydensity"
calculate_groups <- function(., data, na.rm = FALSE, width = NULL,
- scale = c("area", "count", "width"), ...) {
+ scale = "area", ...) {
data <- remove_missing(data, na.rm, "y", name = "stat_ydensity", finite = TRUE)
data <- .super$calculate_groups(., data, na.rm = na.rm, width = width, ...)
# choose how violins are scaled relative to each other
- scale <- match.arg(scale)
+ scale <- match.arg(scale, c("area", "count", "width"))
data$violinwidth <- switch(scale,
# area : keep the original densities but scale them to a max width of 1

0 comments on commit a658737

Please sign in to comment.