Skip to content

Commit

Permalink
Change dependency from data to data.io
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Aug 17, 2018
1 parent 9a6dd2f commit 6a52b03
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Authors@R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
email = "[email protected]"))
Maintainer: Philippe Grosjean <[email protected]>
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
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/chart-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down
14 changes: 8 additions & 6 deletions R/chart.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"))
Expand Down Expand Up @@ -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, "()")))
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
29 changes: 2 additions & 27 deletions man/chart.Rd

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

38 changes: 38 additions & 0 deletions man/combine_charts.Rd

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

0 comments on commit 6a52b03

Please sign in to comment.