diff --git a/AutoPlots_1.0.0.tar.gz b/AutoPlots_1.0.0.tar.gz deleted file mode 100644 index 11c4698..0000000 Binary files a/AutoPlots_1.0.0.tar.gz and /dev/null differ diff --git a/DESCRIPTION b/DESCRIPTION index cc12146..f3f2529 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,9 +1,12 @@ Package: AutoPlots Title: Creating Echarts Visualizations as Easy as Possible -Version: 1.0.0 -Date: 2025-06-21 +Version: 1.0.1 +Date: 2026-02-02 Authors@R: - person("Adrian", "Antico", , "adrianantico@gmail.com", role = c("aut", "cre", "cph")) + c( + person("Adrian", "Antico", , "adrianantico@gmail.com", role = c("aut", "cre", "cph")), + person("David", "Munoz Tord", , "david.munoztord@mailbox.org", role = c("ctb")) + ) Author: Adrian Antico [aut, cre, cph] Maintainer: Adrian Antico Description: Create beautiful and interactive visualizations in a single function call. The 'data.table' package is utilized to perform the data wrangling necessary to prepare your data for the plot types you wish to build, along with allowing fast processing for big data. There are two broad classes of plots available: standard plots and machine learning evaluation plots. There are lots of parameters available in each plot type function for customizing the plots (such as faceting) and data wrangling (such as variable transformations and aggregation). @@ -19,10 +22,13 @@ Imports: e1071, echarts4r, grDevices, + htmltools, + htmlwidgets, lubridate, nortest, quanteda, quanteda.textstats, + rlang, scales, stats Contact: Adrian Antico @@ -30,7 +36,6 @@ Encoding: UTF-8 Language: en-US LazyData: true NeedsCompilation: no -Packaged: 2025-06-21 14:00:00 UTC RoxygenNote: 7.3.3 Suggests: spelling diff --git a/NAMESPACE b/NAMESPACE index eba9efb..8ddf5da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -115,3 +115,5 @@ importFrom(data.table,set) importFrom(data.table,setcolorder) importFrom(data.table,setnames) importFrom(data.table,setorderv) +importFrom(utils,head) +importFrom(utils,tail) diff --git a/NEWS.md b/NEWS.md index b375d3b..378ba5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,43 +1,3 @@ -# AutoPlots 1.0.0 -Initial version - -100% data.table backend for fast data processing - -Chart types: - -Histogram Plots -Density Plots -Box Plots -Probability Plots -Word Cloud -Pie Charts -Donut Plot -Rosetype Plot -Bar Plots -3D Bar Plots -Stacked Bar Plots -Radar Plots -Line Plots -Step Plots -Area Plots -River Plots -Autocorrelation Plot -Partial Autocorrelation Plot -Scatter Plots -3D Scatter Plots -Copula Plots -3D Copula Plots -Correlation Matrix Plots -Parallel Plots -Heatmaps -Calibration Plots -Calibration Scatter Plots -Partital Dependence Plots -Partital Dependence Heatmaps -Variable Importance Plots -Shapely Importance Plots -ROC Plots -Confusion Matrix Heatmaps -Lift Plots -Gain Plots -BinaryMetrics +# AutoPlots 1.0.1 +* Fix: examples +* Fix: Compatibility upgrade for echarts4r 0.5.0 \ No newline at end of file diff --git a/R/GlobalVariables.R b/R/GlobalVariables.R index aca05de..4967a18 100644 --- a/R/GlobalVariables.R +++ b/R/GlobalVariables.R @@ -16,6 +16,9 @@ utils::globalVariables( names = c( + ".", + ".data", + "1 - Recall", "1 - Specificity", "Adrian", "Appointments", @@ -30,6 +33,7 @@ utils::globalVariables( "DateTime", "FP", "Gain", + "GroupLevels", "GroupVariables", "GroupVars", "Importance", @@ -43,6 +47,7 @@ utils::globalVariables( "Independent_Variable7", "Independent_Variable8", "Independent_Variable9", + "Label", "Leads", "Level", "Lift", @@ -58,6 +63,7 @@ utils::globalVariables( "NormalizedStatistics", "NumNull", "P_Predicted", + "PRAUC", "Percentile", "Plot.Polar", "Population", @@ -79,6 +85,8 @@ utils::globalVariables( "Y_Scroll", "V1", "ZVar", + "..CorrVars", + "..CorrVars_num", "classPredict", "i.Metric", "metadata_path", diff --git a/R/PlotFunctions.R b/R/PlotFunctions.R index 4de56ec..beb40aa 100644 --- a/R/PlotFunctions.R +++ b/R/PlotFunctions.R @@ -8831,12 +8831,14 @@ Plot.CorrMatrix <- function(dt = NULL, xaxis.fontSize = 14, Debug = FALSE) { - # Filter out bad vars + # Filter out bad vars and keep only numeric columns x <- c(); for(i in CorrVars) if(dt[, stats::sd(get(i), na.rm = TRUE)] > 0L) x <- c(x, i) CorrVars <- x NN <- dt[,.N] x <- c(); for(i in CorrVars) if(sum(dt[, is.na(get(i))]) / NN <= MaxNAPercent) x <- c(x, i) CorrVars <- x + # Keep only numeric columns + CorrVars <- CorrVars[sapply(dt[, ..CorrVars], is.numeric)] # Plot if(!PreAgg) { @@ -8867,7 +8869,7 @@ Plot.CorrMatrix <- function(dt = NULL, } p1 <- echarts4r::e_charts(data = corr_mat, width = Width, height = Height) - p1 <- echarts4r::e_correlations(e = p1, order = "hclust") + p1 <- echarts4r::e_correlations(e = p1, order = "hclust", columns = colnames(corr_mat)) p1 <- echarts4r::e_tooltip(e = p1, trigger = "axis", backgroundColor = "aliceblue") if(MouseScroll && FacetRows == 1L && FacetCols == 1L) { p1 <- echarts4r::e_datazoom(e = p1, type = "inside", x_index = c(0,1)) @@ -9026,8 +9028,13 @@ Plot.Parallel <- function(dt = NULL, # Build Plot p1 <- echarts4r::e_charts(data = dt1, width = Width, height = Height) +<<<<<<< main + p1 <- echarts4r::e_parallel_(e = p1, columns = CorrVars, opts = list(smooth = TRUE)) + +======= # Metaprog because issue with function accepting vector of names p1 <- echarts4r::e_parallel_(e = p1, vars = names(dt1), opts = list(smooth = TRUE)) +>>>>>>> main p1 <- echarts4r::e_tooltip(e = p1, trigger = "axis", backgroundColor = "aliceblue") if(MouseScroll && FacetRows == 1L && FacetCols == 1L) { @@ -12259,6 +12266,7 @@ Plot.ROC <- function(dt = NULL, #' #' @author Adrian Antico #' @family Model Evaluation +#' @importFrom utils head tail #' #' @param dt source data.table #' @param XVar X-Axis variable name diff --git a/R/PlotFunctions_NEW.R b/R/PlotFunctions_NEW.R index ce56124..b1f2d8d 100644 --- a/R/PlotFunctions_NEW.R +++ b/R/PlotFunctions_NEW.R @@ -39,6 +39,9 @@ #' @param ShowLabels character #' @param Theme "auritus","azul","bee-inspired","blue","caravan","carp","chalk","cool","dark-bold","dark","eduardo", #' "essos","forest","fresh-cut","fruit","gray","green","halloween","helianthus","infographic","inspired", #' "jazz","london","dark","macarons","macarons2","mint","purple-passion","red-velvet","red","roma","royal", #' "sakura","shine","tech-blue","vintage","walden","wef","weforum","westeros","wonderland" #' @param TimeLine logical +#' @param showSymbol logical, show symbols on line +#' @param areaStyle.color hex or color name +#' @param areaStyle.opacity numeric between 0 and 1 #' @param ContainLabel TRUE #' @param Opacity numeric #' @param title.text Title name @@ -373,6 +376,7 @@ Density <- function(dt = NULL, FacetLevels = NULL, TimeLine = FALSE, showSymbol = FALSE, + Opacity = NULL, areaStyle.color = NULL, areaStyle.opacity = NULL, Height = NULL, @@ -678,6 +682,11 @@ Density <- function(dt = NULL, toolbox.iconStyle.shadowOffsetY = NULL, Debug = FALSE) { + # Set Opacity if provided + if(!is.null(Opacity)) { + areaStyle.opacity <- Opacity + } + # Cap number of records if(length(SampleSize) == 0L) SampleSize <- 30000 if(!data.table::is.data.table(dt)) tryCatch({data.table::setDT(dt)}, error = function(x) { @@ -986,7 +995,7 @@ Density <- function(dt = NULL, if(ShowLabels) { p1 <- echarts4r::e_charts_( - dt1 |> dplyr::group_by(get(GroupVar[1L])), + dt1 |> dplyr::group_by(!!rlang::sym(GroupVar[1L])), timeline = TimeLine, dispose = TRUE, darkMode = TRUE, @@ -996,7 +1005,7 @@ Density <- function(dt = NULL, label = list(show = TRUE)) } else { p1 <- echarts4r::e_charts_( - dt1 |> dplyr::group_by(get(GroupVar[1L])), + dt1 |> dplyr::group_by(!!rlang::sym(GroupVar[1L])), timeline = TimeLine, dispose = TRUE, darkMode = TRUE, @@ -11048,6 +11057,7 @@ Step <- function(dt = NULL, #' @param TimeLine Logical #' @param MouseScroll logical, zoom via mouse scroll #' @param ShowSymbol = FALSE +#' @param itemStyle.color hex or color name #' @param title.text Title name #' @param title.subtext Subtitle name #' @param title.link Title as a link @@ -11536,26 +11546,24 @@ River <- function(dt = NULL, if(Debug) print("Plot.River 3") # Minimize data before moving on + # DCast -> redefine YVar -> Proceed as normal (for both PreAgg and non-PreAgg cases) + if(length(YVar) > 1L && length(GroupVar) == 0L) { + dt1 <- data.table::melt.data.table( + data = dt1, + id.vars = XVar, + measure.vars = YVar, + variable.name = "Group", + value.name = "Measures") + YVar <- "Measures" + GroupVar <- "Group" + } + if(!PreAgg) { if(Debug) print("Plot.River 4") - # DCast -> redefine YVar -> Proceed as normal - if(length(YVar) > 1L && length(GroupVar) == 0L) { - dt1 <- data.table::melt.data.table( - data = dt1, - id.vars = XVar, - measure.vars = YVar, - variable.name = "Group", - value.name = "Measures") - YVar <- "Measures" - GroupVar <- "Group" - } else { - dt1 <- data.table::copy(dt) - } - # Define Aggregation function - if(Debug) print("Plot.Calibration.Line # Define Aggregation function") + if(Debug) print("Plot.Calibration.line # Define Aggregation function") aggFunc <- SummaryFunction(AggMethod) # Aggregate data @@ -11566,6 +11574,11 @@ River <- function(dt = NULL, dt1 <- dt1[, lapply(.SD, noquote(aggFunc)), by = c(XVar)] data.table::setorderv(x = dt1, cols = XVar, 1L) } + } else { + # For PreAgg = TRUE, still need to copy if we haven't melted + if(length(YVar) == 1L || length(GroupVar) > 0L) { + dt1 <- data.table::copy(dt1) + } } # Transformation @@ -11590,19 +11603,31 @@ River <- function(dt = NULL, # Build base plot depending on GroupVar availability if(Debug) print("Line no group Echarts") - p1 <- echarts4r::e_charts_( - data = dt1 |> dplyr::group_by(get(GroupVar)), - x = XVar, - dispose = TRUE, - darkMode = TRUE, - width = Width, - height = Height) + + # Create grouping specification based on whether GroupVar exists + if(length(GroupVar) > 0L) { + p1 <- echarts4r::e_charts_( + data = dt1 |> dplyr::group_by(.data[[GroupVar[1L]]]), + x = XVar, + dispose = TRUE, + darkMode = TRUE, + width = Width, + height = Height) + } else { + p1 <- echarts4r::e_charts_( + data = dt1, + x = XVar, + dispose = TRUE, + darkMode = TRUE, + width = Width, + height = Height) + } p1 <- echarts4r::e_river_( e = p1, serie = YVar ) - if (length(itemStyle.color) == length(as.character(unique(dt1[[GroupVar]])))) { + if (length(GroupVar) > 0L && length(itemStyle.color) == length(as.character(unique(dt1[[GroupVar[1L]]])))) { p1 <- echarts4r::e_color(e = p1, color = itemStyle.color) } @@ -21030,6 +21055,11 @@ CorrMatrix <- function(dt = NULL, # Filter out bad vars x <- c(); for(i in CorrVars) if(dt[, stats::sd(get(i), na.rm = TRUE)] > 0L) x <- c(x, i) CorrVars <- x + + # Filter out non-numeric columns + x <- c(); for(i in CorrVars) if(class(dt[[i]])[1L] %in% c('numeric', 'integer', 'double')) x <- c(x, i) + CorrVars <- x + NN <- dt[,.N] x <- c(); for(i in CorrVars) if(sum(dt[, is.na(get(i))]) / NN <= MaxNAPercent) x <- c(x, i) CorrVars <- x @@ -21053,7 +21083,11 @@ CorrMatrix <- function(dt = NULL, corr_mat <- stats::cor(method = tolower(Method), x = dt1) corr_mat <- round(corr_mat, 3) } else { - corr_mat <- dt + # Use only numeric columns and compute correlation + CorrVars_num <- CorrVars[sapply(dt[, ..CorrVars], is.numeric)] + dt_num <- dt[, ..CorrVars_num] + corr_mat <- stats::cor(dt_num, use = "pairwise.complete.obs", method = tolower(Method)) + corr_mat <- round(corr_mat, 3) } if(Debug) { @@ -21229,6 +21263,7 @@ CorrMatrix <- function(dt = NULL, #' #' @param dt source data.table #' @param SampleSize Sample size +#' @param PreAgg logical; if TRUE, data is pre-aggregated #' @param CorrVars vector of variable names #' @param FacetRows Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows #' @param FacetCols Defaults to 1 which causes no faceting to occur horizontally. Otherwise, supply a numeric value for the number of output grid columns @@ -21581,6 +21616,7 @@ CorrMatrix <- function(dt = NULL, #' @export Parallel <- function(dt = NULL, SampleSize = 50000, + PreAgg = TRUE, CorrVars = NULL, FacetRows = 1, FacetCols = 1, diff --git a/R/revised_echarts4r_functions.R b/R/revised_echarts4r_functions.R index 6056e8d..468fe43 100644 --- a/R/revised_echarts4r_functions.R +++ b/R/revised_echarts4r_functions.R @@ -92,6 +92,7 @@ e_grid_full <- function( #' #' @param e An echarts4r object #' @param serie ZVar XVar YVar +#' @param visualMap.show logical #' @param visualMap.min min value #' @param visualMap.max max value #' @param visualMap.orient 'vertical' 'horizontal' diff --git a/cran-comments.md b/cran-comments.md index 858617d..0d904b4 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,5 +1,5 @@ ## R CMD check results -0 errors | 0 warnings | 1 note +0 errors | 0 warnings | 0 notes -* This is a new release. +* This release includes compatibility upgrades for echarts4r 0.5.0 diff --git a/man/Density.Rd b/man/Density.Rd index 5b6f733..266def1 100644 --- a/man/Density.Rd +++ b/man/Density.Rd @@ -15,6 +15,7 @@ Density( FacetLevels = NULL, TimeLine = FALSE, showSymbol = FALSE, + Opacity = NULL, areaStyle.color = NULL, areaStyle.opacity = NULL, Height = NULL, @@ -340,6 +341,14 @@ Density( \item{TimeLine}{logical} +\item{showSymbol}{logical, show symbols on line} + +\item{Opacity}{numeric} + +\item{areaStyle.color}{hex or color name} + +\item{areaStyle.opacity}{numeric between 0 and 1} + \item{Height}{"400px"} \item{Width}{"200px"} @@ -943,8 +952,6 @@ Density( \item{toolbox.iconStyle.shadowOffsetY}{numeric} \item{Debug}{Debugging purposes} - -\item{Opacity}{numeric} } \value{ plot diff --git a/man/Parallel.Rd b/man/Parallel.Rd index 95b0843..9831d52 100644 --- a/man/Parallel.Rd +++ b/man/Parallel.Rd @@ -7,6 +7,7 @@ Parallel( dt = NULL, SampleSize = 50000, + PreAgg = TRUE, CorrVars = NULL, FacetRows = 1, FacetCols = 1, @@ -337,6 +338,8 @@ Parallel( \item{SampleSize}{Sample size} +\item{PreAgg}{logical; if TRUE, data is pre-aggregated} + \item{CorrVars}{vector of variable names} \item{FacetRows}{Defaults to 1 which causes no faceting to occur vertically. Otherwise, supply a numeric value for the number of output grid rows} diff --git a/man/River.Rd b/man/River.Rd index 2da36b4..1eccbc6 100644 --- a/man/River.Rd +++ b/man/River.Rd @@ -277,6 +277,8 @@ River( \item{ShowSymbol}{= FALSE} +\item{itemStyle.color}{hex or color name} + \item{title.text}{Title name} \item{title.subtext}{Subtitle name} diff --git a/man/e_visual_map_full.Rd b/man/e_visual_map_full.Rd index fd6cbe8..d65e08c 100644 --- a/man/e_visual_map_full.Rd +++ b/man/e_visual_map_full.Rd @@ -29,6 +29,8 @@ e_visual_map_full( \item{serie}{ZVar XVar YVar} +\item{visualMap.show}{logical} + \item{visualMap.min}{min value} \item{visualMap.max}{max value}