From 6a52b030f42048516508f6ff4dd2d1b43b6343ff Mon Sep 17 00:00:00 2001 From: phgrosjean Date: Fri, 17 Aug 2018 16:45:46 +0200 Subject: [PATCH] Change dependency from data to data.io --- DESCRIPTION | 2 +- NAMESPACE | 2 +- R/chart-package.R | 2 +- R/chart.R | 14 ++++++++------ man/chart.Rd | 29 ++--------------------------- man/combine_charts.Rd | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 man/combine_charts.Rd diff --git a/DESCRIPTION b/DESCRIPTION index a73c1ac..c61bb5a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,7 +8,7 @@ Authors@R: c(person("Philippe", "Grosjean", role = c("aut", "cre"), email = "phgrosjean@sciviews.org")) Maintainer: Philippe Grosjean Depends: R (>= 3.3.0), lattice, ggplot2 -Imports: stats, utils, rlang, cowplot, grDevices, graphics, scales, latticeExtra, pryr, data, ggplotify, ggpubr +Imports: stats, utils, rlang, cowplot, grDevices, graphics, scales, latticeExtra, pryr, data.io, ggplotify, ggpubr Suggests: covr, knitr, testthat Encoding: UTF-8 ByteCompile: yes diff --git a/NAMESPACE b/NAMESPACE index 1289862..c4c54ca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,7 +22,7 @@ import(grDevices) import(graphics) import(lattice) importFrom(cowplot,theme_cowplot) -importFrom(data,label) +importFrom(data.io,label) importFrom(ggplotify,as.ggplot) importFrom(ggpubr,ggarrange) importFrom(latticeExtra,custom.theme) diff --git a/R/chart-package.R b/R/chart-package.R index 1f1aafd..a96e4ec 100644 --- a/R/chart-package.R +++ b/R/chart-package.R @@ -23,7 +23,7 @@ #' @importFrom stats as.formula asOneSidedFormula #' @importFrom utils modifyList #' @importFrom pryr modify_lang -#' @importFrom data label +#' @importFrom data.io label #' @importFrom ggplotify as.ggplot #' @importFrom ggpubr ggarrange #' diff --git a/R/chart.R b/R/chart.R index 2d1cf55..d26aca3 100644 --- a/R/chart.R +++ b/R/chart.R @@ -19,7 +19,7 @@ #' @keywords hplot #' @concept R plots with graphics, lattice or ggplot2 #' @examples -#' urchin <- data::read("urchin_bio", package = "data", lang = "en") +#' urchin <- data.io::read("urchin_bio", package = "data.io", lang = "en") #' #' # base R graphics #' hist(urchin$height) @@ -38,7 +38,7 @@ #' ggplot(urchin, aes(height)) + geom_histogram() #' #... or with chart (notice similarities with lattice version) #' chart(urchin, ~ height) + geom_histogram() -#' chart$geom_histogram(urchin, ~ height) +#' #chart$geom_histogram(urchin, ~ height) chart <- structure(function(data, ..., type = NULL, env = parent.frame()) { UseMethod("chart") }, class = c("function", "subsettable_type")) @@ -192,7 +192,10 @@ chart.default <- function(data, specif = NULL, formula = NULL, mapping = NULL, fun <- get0(type, envir = env, mode = "function") if (is.null(fun)) stop("function '", type, "' not found") + # With ggplot2 3.0.0, this does not work any more, due to tidyeval p <- p + fun() + # This does not work too! + #eval(parse(text = paste0("p <- p + ", type, "()"))) } } @@ -202,7 +205,7 @@ chart.default <- function(data, specif = NULL, formula = NULL, mapping = NULL, names(labels) <- dnames if (!is.null(dnames)) { for (dname in dnames) - labels[[dname]] <- data::label(data[[dname]], units = TRUE) + labels[[dname]] <- data.io::label(data[[dname]], units = TRUE) labels <- labels[labels != ""] if (length(labels)) { dnames <- names(labels) @@ -266,17 +269,16 @@ env = parent.frame()) { #' @param ncol (optional) number of columns in the plot grid. #' @param nrow (optional) number of rows in the plot grid. #' @param labels (optional) labels to use for each individual plot. `"AUTO"` +#' @param ... further arguments passed to [ggarrange()]. #' (default value) auto-generates uppercase labels, and `"auto"` does the same #' for lowercase labels. -#' @params ... Further arguments to [ggarrange()]. #' @return An object of class `ggarrange` containing a list of `ggplot`s. #' @export -#' @name chart #' @seealso [chart()], [ggarrange()] #' @keywords hplot #' @concept Combine plots on the same page #' @examples -#' urchin <- data::read("urchin_bio", package = "data", lang = "en") +#' # TODO... combine_charts <- function(chartlist, ncol = NULL, nrow = NULL, labels = "AUTO", ...) ggpubr::ggarrange(plotlist = chartlist, ncol = ncol, nrow = nrow, diff --git a/man/chart.Rd b/man/chart.Rd index 4034812..7205ea2 100644 --- a/man/chart.Rd +++ b/man/chart.Rd @@ -5,8 +5,6 @@ \alias{chart.default} \alias{chart.function} \alias{$.subsettable_type} -\alias{chart} -\alias{combine_charts} \title{Create charts} \usage{ chart(data, ..., type = NULL, env = parent.frame()) @@ -19,8 +17,6 @@ chart(data, ..., type = NULL, env = parent.frame()) env = parent.frame()) \method{$}{subsettable_type}(x, name) - -combine_charts(chartlist, ncol = NULL, nrow = NULL, labels = "AUTO", ...) } \arguments{ \item{data}{The dataset (a \code{data.frame} or \code{tibble}, usually).} @@ -42,31 +38,15 @@ combine_charts(chartlist, ncol = NULL, nrow = NULL, labels = "AUTO", ...) \item{x}{A \code{subsettable_type} function.} \item{name}{The value to use for the \code{type=} argument.} - -\item{chartlist}{List of charts to combine.} - -\item{ncol}{(optional) number of columns in the plot grid.} - -\item{nrow}{(optional) number of rows in the plot grid.} - -\item{labels}{(optional) labels to use for each individual plot. \code{"AUTO"} -(default value) auto-generates uppercase labels, and \code{"auto"} does the same -for lowercase labels.} -} -\value{ -An object of class \code{ggarrange} containing a list of \code{ggplot}s. } \description{ \code{chart()} provides a unified interface for base plots, lattice and ggplot2. - -Assemble multiple charts on the same page. Wrapper arround \code{\link[=ggarrange]{ggarrange()}} with -different defaults. } \details{ .... } \examples{ -urchin <- data::read("urchin_bio", package = "data", lang = "en") +urchin <- data.io::read("urchin_bio", package = "data.io", lang = "en") # base R graphics hist(urchin$height) @@ -85,17 +65,12 @@ chart$histogram(urchin, ~ height) ggplot(urchin, aes(height)) + geom_histogram() #... or with chart (notice similarities with lattice version) chart(urchin, ~ height) + geom_histogram() -chart$geom_histogram(urchin, ~ height) -urchin <- data::read("urchin_bio", package = "data", lang = "en") +#chart$geom_histogram(urchin, ~ height) } \seealso{ \code{\link[=f_aes]{f_aes()}}, \code{\link[=ggplot]{ggplot()}} - -\code{\link[=chart]{chart()}}, \code{\link[=ggarrange]{ggarrange()}} } \concept{ R plots with graphics, lattice or ggplot2 - -Combine plots on the same page } \keyword{hplot} diff --git a/man/combine_charts.Rd b/man/combine_charts.Rd new file mode 100644 index 0000000..0fe7d93 --- /dev/null +++ b/man/combine_charts.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chart.R +\name{combine_charts} +\alias{combine_charts} +\title{Combine charts} +\usage{ +combine_charts(chartlist, ncol = NULL, nrow = NULL, labels = "AUTO", ...) +} +\arguments{ +\item{chartlist}{List of charts to combine.} + +\item{ncol}{(optional) number of columns in the plot grid.} + +\item{nrow}{(optional) number of rows in the plot grid.} + +\item{labels}{(optional) labels to use for each individual plot. \code{"AUTO"}} + +\item{...}{further arguments passed to \code{\link[=ggarrange]{ggarrange()}}. +(default value) auto-generates uppercase labels, and \code{"auto"} does the same +for lowercase labels.} +} +\value{ +An object of class \code{ggarrange} containing a list of \code{ggplot}s. +} +\description{ +Assemble multiple charts on the same page. Wrapper arround \code{\link[=ggarrange]{ggarrange()}} with +different defaults. +} +\examples{ +# TODO... +} +\seealso{ +\code{\link[=chart]{chart()}}, \code{\link[=ggarrange]{ggarrange()}} +} +\concept{ +Combine plots on the same page +} +\keyword{hplot}