diff --git a/DESCRIPTION b/DESCRIPTION index 2b651a0..0ddac56 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mschart Type: Package Title: Chart Generation for 'Microsoft Word' and 'Microsoft PowerPoint' Documents -Version: 0.4.0 +Version: 0.4.1.001 Authors@R: c( person("David", "Gohel", role = c("aut", "cre"), email = "david.gohel@ardata.fr"), @@ -31,6 +31,6 @@ Imports: stats, data.table, htmltools, utils URL: https://ardata-fr.github.io/officeverse/, https://ardata-fr.github.io/mschart/ BugReports: https://github.com/ardata-fr/mschart/issues -RoxygenNote: 7.2.2 +RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE) Suggests: tinytest, doconv diff --git a/NAMESPACE b/NAMESPACE index dd8a9ce..5aa7fe7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -35,6 +35,8 @@ importFrom(cellranger,as.range) importFrom(cellranger,cell_limits) importFrom(cellranger,ra_ref) importFrom(cellranger,to_string) +importFrom(data.table,":=") +importFrom(data.table,.N) importFrom(data.table,as.data.table) importFrom(data.table,dcast.data.table) importFrom(data.table,rbindlist) diff --git a/NEWS.md b/NEWS.md index 67f88db..c4b985a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# mschart 0.4.1 + +## Issues + +* fix issue with dcast by making sure all data are preserved. + # mschart 0.4.0 ## New features diff --git a/R/excel_series.R b/R/excel_series.R index 7c5bccc..d19e42d 100644 --- a/R/excel_series.R +++ b/R/excel_series.R @@ -57,17 +57,17 @@ transpose_data <- function(data, vars, group) { } +#' @importFrom data.table := .N dcast_data <- function(data, x, y, group) { dataset <- as.data.table(data) - form_str <- sprintf("%s ~ %s", x, group) + dataset <- dataset[, c(".fake_id.") := list(seq_len(.N)), by = c(x, group)] + form_str <- sprintf("%s + .fake_id. ~ %s", x, group) out <- dcast.data.table( dataset, formula = as.formula(form_str), - fun.aggregate = function(x) { - x - }, fill = NA, value.var = y ) + out$.fake_id. <- NULL setDF(out) out } @@ -96,9 +96,6 @@ transpose_series_bysplit <- function(x) { - - - #' @importFrom stats as.formula #' @importFrom data.table as.data.table dcast.data.table setorderv setnames shape_as_series <- function(x) { diff --git a/man/mschart.Rd b/man/mschart.Rd index 89f9ea1..342635d 100644 --- a/man/mschart.Rd +++ b/man/mschart.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/package.R \docType{package} \name{mschart} -\alias{mschart} \alias{mschart-package} +\alias{mschart} \title{Chart Generation for 'Microsoft Word' and 'Microsoft PowerPoint' Documents} \description{ It lets R users to create Microsoft Office charts from data, and