diff --git a/R/DiscreteDistribution.R b/R/DiscreteDistribution.R index 79710eb..0e06af2 100644 --- a/R/DiscreteDistribution.R +++ b/R/DiscreteDistribution.R @@ -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) } diff --git a/R/DistributionPlot.R b/R/DistributionPlot.R index daef4c2..3922c82 100644 --- a/R/DistributionPlot.R +++ b/R/DistributionPlot.R @@ -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)) { @@ -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) + @@ -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) @@ -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)) { diff --git a/R/DoubleDensity.R b/R/DoubleDensity.R index 065261b..1fd88b7 100644 --- a/R/DoubleDensity.R +++ b/R/DoubleDensity.R @@ -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 + diff --git a/R/DoubleHistogram.R b/R/DoubleHistogram.R index bc04ba0..c80d53b 100644 --- a/R/DoubleHistogram.R +++ b/R/DoubleHistogram.R @@ -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) + diff --git a/R/FitHistoryPlot.R b/R/FitHistoryPlot.R index 62fc8d4..36c4cbf 100644 --- a/R/FitHistoryPlot.R +++ b/R/FitHistoryPlot.R @@ -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) diff --git a/R/HexBinPlot.R b/R/HexBinPlot.R index ff81a8e..c90573c 100644 --- a/R/HexBinPlot.R +++ b/R/HexBinPlot.R @@ -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") + diff --git a/R/PRPlot.R b/R/PRPlot.R index bb93275..8ae8678 100644 --- a/R/PRPlot.R +++ b/R/PRPlot.R @@ -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) + diff --git a/R/PairPlot.R b/R/PairPlot.R index 5b7584d..2504803 100644 --- a/R/PairPlot.R +++ b/R/PairPlot.R @@ -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) } diff --git a/R/ROC.R b/R/ROC.R index 0807eec..1e531d0 100644 --- a/R/ROC.R +++ b/R/ROC.R @@ -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() + @@ -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() @@ -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() @@ -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() @@ -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}. diff --git a/R/ScatterHist.R b/R/ScatterHist.R index 46115f9..b86eeba 100644 --- a/R/ScatterHist.R +++ b/R/ScatterHist.R @@ -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)) { @@ -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) + @@ -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) + diff --git a/R/ScatterHistC.R b/R/ScatterHistC.R index ff6e61a..285c0c0 100644 --- a/R/ScatterHistC.R +++ b/R/ScatterHistC.R @@ -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) + @@ -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)) @@ -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)) + diff --git a/man/plotlyROC.Rd b/man/plotlyROC.Rd index 1ca6f47..7ed517f 100644 --- a/man/plotlyROC.Rd +++ b/man/plotlyROC.Rd @@ -33,9 +33,6 @@ plotlyROC( plotly plot } \description{ -Use \code{plotly} to produce a ROC plot. -} -\details{ Note: any \code{arrange_} warning is a version incompatibility between \code{plotly} and \code{dplyr}. } \examples{