Skip to content

Commit 8de1907

Browse files
committed
Change to snake_case
1 parent c0cd91f commit 8de1907

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

R/position-dodge.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@
8787
#' ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) +
8888
#' geom_bar(position = position_dodge2(preserve = "total"))
8989
position_dodge <- function(width = NULL, preserve = "total", orientation = "x",
90-
reverse = FALSE, stackOverlap = "no") {
90+
reverse = FALSE, stack_overlap = "no") {
9191
check_bool(reverse)
9292
ggproto(NULL, PositionDodge,
9393
width = width,
9494
preserve = arg_match0(preserve, c("total", "single")),
9595
orientation = arg_match0(orientation, c("x", "y")),
96-
stackOverlap = arg_match0(stackOverlap, c("no","byExtent","byCenter")),
96+
stack_overlap = arg_match0(stack_overlap, c("no","by_extent","by_center")),
9797
reverse = reverse
9898
)
9999
}
@@ -105,7 +105,7 @@ position_dodge <- function(width = NULL, preserve = "total", orientation = "x",
105105
PositionDodge <- ggproto("PositionDodge", Position,
106106
width = NULL,
107107
preserve = "total",
108-
stackOverlap = "no",
108+
stack_overlap = "no",
109109
orientation = "x",
110110
reverse = NULL,
111111
default_aes = aes(order = NULL),
@@ -138,7 +138,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
138138

139139
list(
140140
width = self$width,
141-
stackOverlap = self$stackOverlap,
141+
stack_overlap = self$stack_overlap,
142142
n = n,
143143
flipped_aes = flipped_aes,
144144
reverse = self$reverse %||% FALSE
@@ -183,7 +183,7 @@ PositionDodge <- ggproto("PositionDodge", Position,
183183

184184
# Dodge overlapping interval.
185185
# Assumes that each set has the same horizontal position.
186-
pos_dodge <- function(df, width, n = NULL, stackOverlap = "no") {
186+
pos_dodge <- function(df, width, n = NULL, stack_overlap = "no") {
187187
if (is.null(n)) {
188188
n <- vec_unique_count(df$group)
189189
}
@@ -208,13 +208,13 @@ pos_dodge <- function(df, width, n = NULL, stackOverlap = "no") {
208208
df$xmin <- df$x - d_width / n / 2
209209
df$xmax <- df$x + d_width / n / 2
210210

211-
if (stackOverlap == "byExtent") {
211+
if (stack_overlap == "by_extent") {
212212
# The code chunk below is just to implement the following line without tidyverse functions, as ggplot2 can be imported without that
213213
# df %>% group_by(group) %>% mutate(ymaxx = cumsum(ymax)) %>% mutate(ymin = ymaxx-ymax, ymax = ymaxx)
214214

215215
df$ymaxx = NA # Initialize the variable. This will store the desired top of the group
216-
groupIDs = unique(df$group) # Collect the unique groupIDs. Thi
217-
for (gid in groupIDs) {
216+
group_ids = unique(df$group) # Collect the unique groupIDs. Thi
217+
for (gid in group_ids) {
218218
df$ymaxx[df$group == gid] = cumsum(df$ymax[df$group == gid])
219219
}
220220
# Create the new y placements
@@ -223,14 +223,14 @@ pos_dodge <- function(df, width, n = NULL, stackOverlap = "no") {
223223

224224
df$ymaxx = NULL # Remove the extra variable
225225

226-
} else if (stackOverlap == "byCenter") {
226+
} else if (stack_overlap == "by_center") {
227227
# Similarly to above, the complicated code below is just to do the next line without tidyverse
228228
# df %>% group_by(group) %>% mutate(extent = ymax-ymin, ymaxx = cumsum((ymax+ymin)/2)) %>% mutate(ymin = ymaxx-extent/2, ymax = ymaxx+extent/2)
229229

230230
df$ymaxx = NA # Initialize the variable. This will store the desired top of the group
231231
df$extent = NA # Initialize the variable storing the extent of the geom
232-
groupIDs = unique(df$group) # Collect the unique groupIDs. Thi
233-
for (gid in groupIDs) {
232+
group_ids = unique(df$group) # Collect the unique groupIDs. Thi
233+
for (gid in group_ids) {
234234
df$ymaxx[df$group == gid] = cumsum((df$ymax[df$group == gid] + df$ymin[df$group == gid])/2)
235235
}
236236
df$extent = df$ymax - df$ymin

0 commit comments

Comments
 (0)