Skip to content

Commit a65a87b

Browse files
committed
refactor: replace deprecated aes_string
1 parent cfd416f commit a65a87b

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

R/dataPlot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ plotData <- function(data, group = NULL, col = NULL, addId = TRUE, addBorder = T
9090

9191
p <- ggplot() +
9292
geom_rect(data = d_graph,
93-
mapping = aes_string(xmin = "t_start", xmax = "t_end", ymin = "position - 0.5",
94-
ymax = "position + 0.5", fill = "state"),
93+
mapping = aes(xmin = .data$t_start, xmax = .data$t_end, ymin = .data$position - 0.5,
94+
ymax = .data$position + 0.5, fill = .data$state),
9595
color = ifelse(addBorder, "black", NA)) +
9696
scale_x_continuous(name = "Time") +
9797
labs(fill = "State")

R/plotEncoding.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ plotEncodingCI <- function(fdmat, variance, coeff = 2, states = NULL, harm = 1,
8585
State = factor(rep(colnames(fdmat$y)[i], each = nrow(fdmat$y)), levels = colnames(fdmat$y))
8686
)
8787
p <- p + geom_ribbon(
88-
data = df, aes_string(ymin = "ymin", ymax = "ymax", x = "time", fill = "State"),
88+
data = df, aes(ymin = .data$ymin, ymax = .data$ymax, x = .data$time, fill = .data$State),
8989
colour = NA, alpha = 0.8
9090
)
9191
}
@@ -98,7 +98,7 @@ plotEncodingCI <- function(fdmat, variance, coeff = 2, states = NULL, harm = 1,
9898
df <- df[df$State %in% states, ]
9999

100100
p <- p +
101-
geom_line(data = df, mapping = aes_string(x = "x", y = "y", group = "State", colour = "State"), alpha = 1) +
101+
geom_line(data = df, mapping = aes(x = .data$x, y = .data$y, group = .data$State, colour = .data$State), alpha = 1) +
102102
scale_colour_hue(l = 30, drop = FALSE)
103103

104104
p <- p +
@@ -123,7 +123,7 @@ plotEncoding <- function(fdmat, states = NULL, harm = 1, col = NULL) {
123123
)
124124

125125
df <- df[df$State %in% states, ]
126-
p <- ggplot(df, aes_string(x = "x", y = "y", group = "State", colour = "State")) +
126+
p <- ggplot(df, aes(x = .data$x, y = .data$y, group = .data$State, colour = .data$State)) +
127127
geom_line()
128128

129129
p <- p +
@@ -292,12 +292,12 @@ plotComponent <- function(x, comp = c(1, 2), addNames = TRUE, nudge_x = 0.1, nud
292292
df <- as.data.frame(Re(x$pc))
293293
df$name <- rownames(x$pc)
294294

295-
p <- ggplot(df, aes_string(x = paste0("V", comp[1]), y = paste0("V", comp[2]))) +
295+
p <- ggplot(df, aes(x = .data[[paste0("V", comp[1])]], y = .data[[paste0("V", comp[2])]])) +
296296
geom_point(...) +
297297
labs(x = paste0("Comp ", comp[1]), y = paste0("Comp ", comp[2]))
298298

299299
if (addNames) {
300-
p <- p + geom_text(aes_string(label = "name"), nudge_x = nudge_x, nudge_y = nudge_y, size = size)
300+
p <- p + geom_text(aes(label = .data$name), nudge_x = nudge_x, nudge_y = nudge_y, size = size)
301301
}
302302

303303
p
@@ -366,7 +366,7 @@ plotEigenvalues <- function(x, cumulative = FALSE, normalize = FALSE, ...) {
366366

367367
df <- data.frame(eigenvalues = eigenv, component = comp)
368368

369-
p <- ggplot(df, aes_string(x = "component", y = "eigenvalues")) +
369+
p <- ggplot(df, aes(x = .data$component, y = .data$eigenvalues)) +
370370
geom_point(...) +
371371
geom_step() +
372372
labs(

R/stat.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ compute_time_spent_intern <- function(data, labels) {
9797
#' @export
9898
boxplot.timeSpent <- function(x, col = NULL, ...) {
9999
df <- data.frame(timeSpent = as.vector(x), state = factor(rep(colnames(x), each = nrow(x)), levels = colnames(x)))
100-
p <- ggplot(df, aes_string(x = "state", y = "timeSpent", fill = "state")) +
100+
p <- ggplot(df, aes(x = .data$state, y = .data$timeSpent, fill = .data$state)) +
101101
geom_boxplot(...) +
102102
labs(x = "State", y = "Time Spent", fill = "State")
103103

@@ -189,7 +189,7 @@ hist.duration <- function(x, breaks = NULL, ...) {
189189
defaultParam <- list(fill = "lightblue", color = "black", bins = breaks)
190190
param <- c(extraParam, defaultParam[which(!(names(defaultParam) %in% names(extraParam)))])
191191

192-
ggplot(data.frame(duration = as.vector(x)), aes_string(x = "duration")) +
192+
ggplot(data.frame(duration = as.vector(x)), aes(x = .data$duration)) +
193193
do.call(geom_histogram, param) +
194194
labs(x = "Duration", y = "Frequency")
195195
}
@@ -426,7 +426,7 @@ plot_pt_classic <- function(pt, col = NULL) {
426426
time = rep(pt$t, nrow(pt$pt))
427427
)
428428

429-
p <- ggplot(plot_data, aes_string(x = "time", y = "proba", group = "State", colour = "State")) +
429+
p <- ggplot(plot_data, aes(x = .data$time, y = .data$proba, group = .data$State, colour = .data$State)) +
430430
geom_line() +
431431
ylim(0, 1) +
432432
labs(x = "Time", y = "p(t)", title = "P(X(t) = x)")
@@ -460,12 +460,14 @@ plot_pt_ribbon <- function(pt, col = NULL, addBorder = TRUE) {
460460

461461
p <- ggplot(plot_data)
462462
for (i in seq_len(nState)) {
463-
p <- p + geom_ribbon(aes_string(
464-
ymin = paste0("`", labels[i], "`"),
465-
ymax = paste0("`", labels[i + 1], "`"), x = "time",
466-
fill = shortLabels[i]
467-
),
468-
colour = ifelse(addBorder, "black", NA), alpha = 0.8
463+
p <- p + geom_ribbon(
464+
aes(
465+
ymin = .data[[labels[i]]],
466+
ymax = .data[[labels[i + 1]]],
467+
x = .data$time,
468+
fill = shortLabels[i]
469+
),
470+
colour = ifelse(addBorder, "black", NA), alpha = 0.8
469471
)
470472
}
471473

@@ -575,7 +577,7 @@ hist.njump <- function(x, breaks = NULL, ...) {
575577
defaultParam <- list(fill = "lightblue", color = "black", bins = breaks, center = 0)
576578
param <- c(extraParam, defaultParam[which(!(names(defaultParam) %in% names(extraParam)))])
577579

578-
ggplot(data.frame(njump = as.vector(x)), aes_string(x = "njump")) +
580+
ggplot(data.frame(njump = as.vector(x)), aes(x = .data$njump)) +
579581
do.call(geom_histogram, param) +
580582
labs(x = "Number of jumps", y = "Frequency") +
581583
scale_x_continuous(breaks = function(x) pretty(seq(ceiling(x[1]), floor(x[2]), by = 1)))

0 commit comments

Comments
 (0)