Skip to content

Commit

Permalink
remove use of aes_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMount committed Apr 14, 2023
1 parent 3e8aad1 commit 30c4f64
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 69 deletions.
2 changes: 1 addition & 1 deletion R/DiscreteDistribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DiscreteDistribution = function(frm, xvar, title, ...,
} else {
geom="point"
}
ggplot2::ggplot(frm, ggplot2::aes_string(xvar, "unit")) +
ggplot2::ggplot(data = frm, mapping = ggplot2::aes(!!!simulate_aes_string(x = xvar, y = "unit"))) +
ggplot2::stat_summary(fun=sum, fun.max=sum, fun.min=function(x){0}, geom=geom, color=color) +
ggplot2::ggtitle(title)
}
14 changes: 7 additions & 7 deletions R/DistributionPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ PlotDistDensityNormal <- function(frm, xvar, title, ...,
dDist$density <- dnorm(dDist[[xvar]],mean=meanx,sd=sdx)
plt = ggplot2::ggplot() +
ggplot2::geom_density(data=dPlot,
mapping=ggplot2::aes_string(x=xvar),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar)),
fill = curve_color,
color = NA,
adjust=adjust) +
ggplot2::geom_line(data=dDist,
mapping=ggplot2::aes_string(x=xvar,y='density'),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y='density')),
color=normal_color,linetype=2) +
ggplot2::geom_vline(xintercept=meanx,color=mean_color,linetype=2)
if(!is.null(sd_color)) {
Expand Down Expand Up @@ -155,7 +155,7 @@ PlotDistCountNormal <- function(frm, xvar, title,
subtitle = paste('binWidth =', format(binWidth))

plt = ggplot2::ggplot(data=dHist,
mapping=ggplot2::aes_string(x=xvar,y='count',ymax='count')) +
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y='count',ymax='count'))) +
ggplot2::geom_linerange(data=dTheory,ggplot2::aes(ymin=0),size=4,alpha=0.5,color=normal_color) +
ggplot2::geom_point(color=hist_color, size=4) +
ggplot2::geom_linerange(ggplot2::aes(ymin=0),color=hist_color, size=2) +
Expand Down Expand Up @@ -237,12 +237,12 @@ PlotDistDensityBeta <- function(frm, xvar, title, ...,
dDist$density <- dbeta(dDist[[xvar]],shape1=shape1,shape2=shape2)
plt = ggplot2::ggplot() +
ggplot2::geom_density(data=dPlot,
mapping=ggplot2::aes_string(x=xvar),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar)),
adjust=0.5,
fill = curve_color,
color = NA) +
ggplot2::geom_line(data=dDist,
mapping=ggplot2::aes_string(x=xvar,y='density'),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y='density')),
color=beta_color,linetype=2) +
ggplot2::geom_vline(xintercept=meanx,color=mean_color,linetype=2)

Expand Down Expand Up @@ -336,11 +336,11 @@ PlotDistHistBeta <- function(frm, xvar, title,

plt = ggplot2::ggplot() +
ggplot2::geom_histogram(data=dPlot,
mapping=ggplot2::aes_string(x=xvar),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar)),
bins = bins,
fill=hist_color, color=NA) +
ggplot2::geom_line(data=dDist,
mapping=ggplot2::aes_string(x=xvar,y='count'),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y='count')),
color=beta_color,linetype=2) +
ggplot2::geom_vline(xintercept=meanx,color=mean_color,linetype=2)
if(!is.null(sd_color)) {
Expand Down
8 changes: 4 additions & 4 deletions R/DoubleDensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ DoubleDensityPlot <- function(frame, xvar, truthVar, title,
# display.brewer.all()
palletName = palette
plt <- ggplot2::ggplot(data=pf,
mapping=ggplot2::aes_string(x=xvar,y='density',
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y='density',
ymin='zero',ymax='density',
color=truthVar,fill=truthVar,
linetype=truthVar
))
)))
if(sum(!is.na(pf$density))>0) {
plt <- plt + ggplot2::geom_line() +
ggplot2::geom_ribbon(alpha=0.5,color=NA)
}
if(sum(!is.na(pf$xintercept))>0) {
plt <- plt + ggplot2::geom_vline(data=pf,
mapping=ggplot2::aes_string(color=truthVar,linetype=truthVar,
xintercept='xintercept'))
mapping=ggplot2::aes(!!!simulate_aes_string(color=truthVar,linetype=truthVar,
xintercept='xintercept')))
}
if(!is.null(palette)) {
plt = plt +
Expand Down
10 changes: 5 additions & 5 deletions R/DoubleHistogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ DoubleHistogramPlot <- function(frame, xvar, truthVar, title, ...,
error = function(e) { NA }
)
pf$net <- sm
plot <- ggplot2::ggplot(data=pf,mapping=ggplot2::aes_string(x=xvar,
color=truthVar,fill=truthVar,linetype=truthVar)) +
ggplot2::geom_bar(mapping=ggplot2::aes_string(y='count'),
plot <- ggplot2::ggplot(data=pf,mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,
color=truthVar,fill=truthVar,linetype=truthVar))) +
ggplot2::geom_bar(mapping=ggplot2::aes(!!!simulate_aes_string(y='count')),
stat='identity',alpha=0.5,position='identity')
if(sum(!is.na(pf$smooth))>1) {
plot <- plot +
ggplot2::geom_line(mapping=ggplot2::aes_string(y='smooth'))
ggplot2::geom_line(mapping=ggplot2::aes(!!!simulate_aes_string(y='smooth')))
}
if(sum(!is.na(pf$net))>1) {
plot <- plot +
ggplot2::geom_line(mapping=ggplot2::aes_string(y='net'),linetype=3,color='black')
ggplot2::geom_line(mapping=ggplot2::aes(!!!simulate_aes_string(y='net')),linetype=3,color='black')
}
if(!is.null(palette)) {
plot = plot + ggplot2::scale_fill_brewer(palette=palletName) +
Expand Down
14 changes: 7 additions & 7 deletions R/FitHistoryPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ plot_fit_trajectory <- function(d,
d$validation)
}


valCol = val_color
trainCol = train_color
pickCol = pick_color

plt <- ggplot2::ggplot(
data = d,
ggplot2::aes_string(x = epoch_name,
xend = epoch_name,
y = "validation",
yend = "training",
ymin = "rmin",
ymax = "rmax")) +
mapping = ggplot2::aes(!!!simulate_aes_string(
x = epoch_name,
xend = epoch_name,
y = "validation",
yend = "training",
ymin = "rmin",
ymax = "rmax"))) +
ggplot2::geom_point(color=valCol) +
ggplot2::geom_point(ggplot2::aes(y = training), color=trainCol)

Expand Down
4 changes: 3 additions & 1 deletion R/HexBinPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ HexBinPlot <- function(d, xvar, yvar, title,
title = title,
funname = "WVPlots::HexBinPlot")

ggplot2::ggplot(d, ggplot2::aes_string(x=xvar, y=yvar)) +
ggplot2::ggplot(
data = d,
mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar, y=yvar))) +
ggplot2::geom_hex(bins = bins, binwidth = binwidth, na.rm = na.rm) +
ggplot2::ggtitle(title) +
ggplot2::scale_fill_gradient(low = lightcolor, high = darkcolor, space = "Lab") +
Expand Down
8 changes: 4 additions & 4 deletions R/PRPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ PRPlot <- function(frame, xvar, truthVar, truthTarget, title,
if(nrow(pF1)<1000) {
plot <- plot +
ggplot2::geom_point(data=pf,
ggplot2::aes_string(x='Recall',y='Precision'),
mapping=ggplot2::aes(x=Recall, y=Precision),
color='darkblue',alpha=0.5)
}
plot <- plot +
ggplot2::geom_point(data=pF1,
ggplot2::aes_string(x='Recall',y='Precision'),
mapping=ggplot2::aes(x=Recall, y=Precision),
color='blue',size=2,shape=15) +
ggplot2::geom_line(data=prList$lineGraph,
ggplot2::aes_string(x='Recall',y='Precision'),
mapping=ggplot2::aes(x=Recall, y=Precision),
color='darkblue') +
ggplot2::geom_line(data=isoFrame,
ggplot2::aes_string(x='Recall',y='Precision'),
mapping=ggplot2::aes(x=Recall, y=Precision),
color='blue',alpha=0.5,linetype=2) +
ggplot2::geom_hline(yintercept=prevalence, linetype=3, alpha=0.2) +
ggplot2::geom_vline(xintercept=1, linetype=3, alpha=0.2) +
Expand Down
4 changes: 2 additions & 2 deletions R/PairPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ PairPlot <- function(d, meas_vars, title,

x <- y <- NULL # don't look like unbound references to checker

plt = ggplot2::ggplot(d_aug, ggplot2::aes(x=x, y=y))
plt = ggplot2::ggplot(data = d_aug, mapping = ggplot2::aes(x=x, y=y))

if(length(group_var) == 1) {
plt = plt +
ggplot2::geom_point(ggplot2::aes_string(color=group_var), alpha=alpha)
ggplot2::geom_point(mapping = ggplot2::aes(!!!simulate_aes_string(color=group_var), alpha=alpha))
} else {
plt = plt + ggplot2::geom_point(alpha=alpha, color=point_color)
}
Expand Down
50 changes: 24 additions & 26 deletions R/ROC.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ ROCPlot <- function(frame, xvar, truthVar, truthTarget, title,
}
plot <- ggplot2::ggplot() +
ggplot2::geom_ribbon(data=rocList$lineGraph,
ggplot2::aes_string(x='FalsePositiveRate',
ymax='TruePositiveRate',ymin=0),
mapping=ggplot2::aes(x=FalsePositiveRate,
ymax=TruePositiveRate,ymin=0),
alpha=0.2,color=NA, fill=fill_color)
if(nrow(rocList$pointGraph)<=1000) {
plot <- plot +
ggplot2::geom_point(data=rocList$pointGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate'),
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate),
color=curve_color, alpha=0.5)
}
plot <- plot +
ggplot2::geom_line(data=rocList$lineGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate'),
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate),
color=curve_color) +
ggplot2::geom_abline(slope=1,intercept=0,color=diag_color) +
ggplot2::coord_fixed() +
Expand Down Expand Up @@ -396,16 +396,16 @@ ROCPlotPair <- function(frame, xvar1, xvar2, truthVar, truthTarget, title,
plot <- ggplot2::ggplot()
if(nrow(pointGraph)<=1000) {
plot <- plot + ggplot2::geom_point(data=pointGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='model',shape='model'),
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=model,shape=model),
alpha=0.5)
}
plot <- plot +
ggplot2::geom_line(data=lineGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='model',linetype='model')) +
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=model,linetype=model)) +
ggplot2::geom_abline(slope=1,intercept=0,color='gray') +
ggplot2::coord_fixed()

Expand Down Expand Up @@ -512,16 +512,16 @@ ROCPlotList <- function(
plot <- ggplot2::ggplot()
if(nrow(pointGraph)<=1000) {
plot <- plot + ggplot2::geom_point(data=pointGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='model',shape='model'),
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=model,shape=model),
alpha=0.5)
}
plot <- plot +
ggplot2::geom_line(data=lineGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='model',linetype='model')) +
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=model,linetype=model)) +
ggplot2::geom_abline(slope=1,intercept=0,color='gray') +
ggplot2::coord_fixed()

Expand Down Expand Up @@ -655,16 +655,16 @@ ROCPlotPair2 <- function(nm1, frame1, xvar1, truthVar1, truthTarget1,
if(nrow(pointGraph)<=1000) {
plot <- plot +
ggplot2::geom_point(data=pointGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='dataset',shape='dataset'),
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=dataset,shape=dataset),
alpha=0.5)
}
plot <- plot +
ggplot2::geom_line(data=lineGraph,
ggplot2::aes_string(x='FalsePositiveRate',
y='TruePositiveRate',
color='dataset',linetype='dataset')) +
mapping=ggplot2::aes(x=FalsePositiveRate,
y=TruePositiveRate,
color=dataset,linetype=dataset)) +
ggplot2::geom_abline(slope=1,intercept=0,color='gray') +
ggplot2::coord_fixed()

Expand All @@ -691,8 +691,6 @@ ROCPlotPair2 <- function(nm1, frame1, xvar1, truthVar1, truthTarget1,



#' Use \code{plotly} to produce a ROC plot.
#'
#' Use \code{plotly} to produce a ROC plot.
#'
#' Note: any \code{arrange_} warning is a version incompatibility between \code{plotly} and \code{dplyr}.
Expand Down
6 changes: 3 additions & 3 deletions R/ScatterHist.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ScatterHist = function(frame, xvar, yvar, title, ...,
}

# scatterplot of x and y
plot_center = ggplot2::ggplot(frame, ggplot2::aes_string(x=xvar,y=yvar)) +
plot_center = ggplot2::ggplot(data = frame, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar,y=yvar))) +
ggplot2::geom_point(color=point_color, alpha=point_alpha) +
ggplot2::theme(plot.margin = grid::unit(c(0, 0, 0, 0), "lines"))
if(!is.null(gSmooth)) {
Expand Down Expand Up @@ -185,7 +185,7 @@ ScatterHist = function(frame, xvar, yvar, title, ...,
# 0,0,1,0 -- bottom gap bigger
# 0,0,0,1 -- left side is shorter
#
plot_top <- ggplot2::ggplot(frame, ggplot2::aes_string(x=xvar)) +
plot_top <- ggplot2::ggplot(data = frame, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar))) +
ggplot2::geom_histogram(ggplot2::aes(y=..density..), fill=hist_color,
color="white", binwidth=binwidth_x, bins=30) +
ggplot2::geom_line(stat='density',color=density_color, adjust=adjust_x) +
Expand Down Expand Up @@ -219,7 +219,7 @@ ScatterHist = function(frame, xvar, yvar, title, ...,
# xBreaks <- cRanges$x.major_source

# marginal density of y - plot on the right
plot_right <- ggplot2::ggplot(frame, ggplot2::aes_string(x=yvar)) +
plot_right <- ggplot2::ggplot(data = frame, mapping = ggplot2::aes(!!!simulate_aes_string(x=yvar))) +
ggplot2::geom_histogram(ggplot2::aes(y=..density..), fill=hist_color,
color="white", binwidth=binwidth_y, bins=30) +
ggplot2::geom_line(stat='density',color=density_color, adjust=adjust_y) +
Expand Down
12 changes: 6 additions & 6 deletions R/ScatterHistC.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ ScatterHistC = function(frame, xvar, yvar, cvar, title, ...,


# scatterplot of x and y
plot_center = ggplot2::ggplot(frame,
ggplot2::aes_string(x=xvar,y=yvar,color=cvar)) +
plot_center = ggplot2::ggplot(data = frame,
mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar,y=yvar,color=cvar))) +
ggplot2::geom_point() +
ggplot2::theme(plot.margin = grid::unit(c(0, 0, 0, 0), "lines")) +
ggplot2::scale_color_brewer(palette=colorPalette) +
Expand Down Expand Up @@ -123,8 +123,8 @@ ScatterHistC = function(frame, xvar, yvar, cvar, title, ...,
# 0,0,1,0 -- bottom gap bigger
# 0,0,0,1 -- left side is shorter
#
plot_top <- ggplot2::ggplot(frame,
ggplot2::aes_string(x=xvar,color=cvar)) +
plot_top <- ggplot2::ggplot(data = frame,
mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar,color=cvar))) +
ggplot2::geom_line(stat='density',adjust=adjust_x) +
ggplot2::coord_cartesian(xlim=xlims) +
ggplot2::scale_x_continuous(expand = c(0,0))
Expand All @@ -144,8 +144,8 @@ ScatterHistC = function(frame, xvar, yvar, cvar, title, ...,


# marginal density of y - plot on the right
plot_right <- ggplot2::ggplot(frame,
ggplot2::aes_string(x=yvar,color=cvar)) +
plot_right <- ggplot2::ggplot(data = frame,
mapping = ggplot2::aes(!!!simulate_aes_string(x=yvar,color=cvar))) +
ggplot2::geom_line(stat='density', adjust=adjust_y) +
# ggplot2::coord_cartesian(xlim=ylims) + # causes a warning with ggplot2 2.2.1.9000
ggplot2::scale_x_continuous(expand = c(0,0)) +
Expand Down
3 changes: 0 additions & 3 deletions man/plotlyROC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 30c4f64

Please sign in to comment.