Skip to content

Commit

Permalink
Remove plyr dependency
Browse files Browse the repository at this point in the history
It doesn't seem to be particularly necessary. This would be helpful for us in https://github.com/easystats/see. We try to limit the number of downstream dependencies we import.
  • Loading branch information
bwiernik committed May 18, 2021
1 parent b5b603a commit d6108e7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Expand Up @@ -18,7 +18,6 @@ Depends:
Imports:
ggplot2 (>= 3.0.0),
grid (>= 3.0.0),
plyr (>= 1.8.0),
scales (>= 0.4.1),
withr (>= 2.1.1)
License: GPL-2 | file LICENSE
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Expand Up @@ -70,6 +70,5 @@ importFrom(ggplot2,ggproto)
importFrom(ggplot2,layer)
importFrom(grid,gList)
importFrom(grid,gTree)
importFrom(plyr,summarise)
importFrom(scales,train_discrete)
importFrom(stats,quantile)
13 changes: 10 additions & 3 deletions R/geoms-gradient.R
Expand Up @@ -239,7 +239,11 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,
data <- data[!missing_pos,]

# munching for line
positions <- plyr::summarise(data, x = x, y = ymax, id = ids)
positions <- with(data, data.frame(
x = x,
y = ymax,
id = ids
))
munched_line <- ggplot2::coord_munch(coord, positions, panel_params)

# We now break down the polygons further by fill color, since
Expand Down Expand Up @@ -267,8 +271,11 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,
}

# munching for polygon
positions <- plyr::summarise(data,
x = c(x, rev(x)), y = c(ymax, rev(ymin)), id = c(ids, rev(ids)))
positions <- with(data, data.frame(
x = c(x, rev(x)),
y = c(ymax, rev(ymin)),
id = c(ids, rev(ids))
))
munched_poly <- ggplot2::coord_munch(coord, positions, panel_params)

# calculate line and area grobs
Expand Down
14 changes: 10 additions & 4 deletions R/geoms.R
Expand Up @@ -97,7 +97,6 @@ geom_ridgeline <- function(mapping = NULL, data = NULL, stat = "identity",
#' @format NULL
#' @usage NULL
#' @importFrom ggplot2 ggproto Geom
#' @importFrom plyr summarise
#' @export
GeomRidgeline <- ggproto("GeomRidgeline", Geom,
default_aes = aes(
Expand Down Expand Up @@ -258,12 +257,19 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
ids[missing_pos] <- NA

# munching for polygon
positions <- plyr::summarise(data,
x = c(x, rev(x)), y = c(ymax, rev(ymin)), id = c(ids, rev(ids)))
positions <- with(data, data.frame(
x = c(x, rev(x)),
y = c(ymax, rev(ymin)),
id = c(ids, rev(ids))
))
munched_poly <- ggplot2::coord_munch(coord, positions, panel_params)

# munching for line
positions <- plyr::summarise(data, x = x, y = ymax, id = ids)
positions <- with(data, data.frame(
x = x,
y = ymax,
id = ids
))
munched_line <- ggplot2::coord_munch(coord, positions, panel_params)

# calculate line and area grobs
Expand Down
14 changes: 10 additions & 4 deletions R/geomsv.R
Expand Up @@ -93,7 +93,6 @@ geom_vridgeline <- function(mapping = NULL, data = NULL, stat = "identity",
#' @format NULL
#' @usage NULL
#' @importFrom ggplot2 ggproto Geom draw_key_polygon
#' @importFrom plyr summarise
#' @export
GeomVRidgeline <- ggproto("GeomVRidgeline", Geom,
default_aes = aes(color = "black", fill = "grey80", x = 0, size = 0.5, linetype = 1,
Expand Down Expand Up @@ -173,12 +172,19 @@ GeomVRidgeline <- ggproto("GeomVRidgeline", Geom,
ids[missing_pos] <- NA

# munching for polygon
positions <- plyr::summarise(data,
y = c(y, rev(y)), x = c(xmax, rev(xmin)), id = c(ids, rev(ids)))
positions <- with(data, data.frame(
y = c(y, rev(y)),
x = c(xmax, rev(xmin)),
id = c(ids, rev(ids))
))
munched_poly <- ggplot2::coord_munch(coord, positions, panel_params)

# munching for line
positions <- plyr::summarise(data, y = y, x = xmax, id = ids)
positions <- with(data, data.frame(
y = y,
x = xmax,
id = ids
))
munched_line <- ggplot2::coord_munch(coord, positions, panel_params)

# placing the actual grob generation into a separate function allows us to override for geom_density_ridges2
Expand Down

0 comments on commit d6108e7

Please sign in to comment.