Browse Source

synch with upstream

Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	DESCRIPTION
#	README.md
#	README_figs/README-bkde2d-2.png
#	README_figs/README-bkde_ash-5.png
#	README_figs/README-bkde_ash-6.png
#	README_figs/README-coord_proj-1.png
#	README_figs/README-dumbbell2-1.png
#	README_figs/README-horizon-1.png
#	README_figs/README-splines-1.png
#	README_figs/README-splines-2.png
#	README_figs/README-splines-3.png
#	README_figs/README-splines-4.png
#	README_figs/README-splines-5.png
#	README_figs/README-splines-6.png
#	README_figs/README-splines-7.png
#	README_figs/README-splines-8.png
#	man/geom_dumbbell.Rd
pull/50/head
yoni sidi 6 years ago
parent
commit
41df89d628
  1. 6
      .Rbuildignore
  2. 8
      DESCRIPTION
  3. 2
      NAMESPACE
  4. 2
      NEWS.md
  5. 87
      R/formatters.r
  6. 23
      R/geom_dumbbell.R
  7. 3
      R/geom_ubar.r
  8. 14
      R/geom_xspline.r
  9. 122
      R/position-dodgev.R
  10. 4
      R/stat-stepribbon.r
  11. 2
      R/stateface.r
  12. 6
      README.Rmd
  13. 11
      README.md
  14. 45
      appveyor.yml
  15. 13
      man/byte_format.Rd
  16. 22
      man/geom_dumbbell.Rd
  17. 3
      man/geom_spikelines.Rd
  18. 4
      man/geom_ubar.Rd
  19. 39
      man/position-dodgev.Rd
  20. 2
      man/stat_stepribbon.Rd
  21. 18
      vignettes/ggalt_examples.Rmd

6
.Rbuildignore

@ -1,10 +1,8 @@
^.*\.Rproj$ ^.*\.Rproj$
^\.Rproj\.user$ ^\.Rproj\.user$
^README\.Rmd$ ^README.*$
^README-.*\.png$
^\.travis\.yml$ ^\.travis\.yml$
^CONDUCT\.md$ ^CONDUCT\.md$
^README_figs
^README\.html$
^cran-comments\.md$ ^cran-comments\.md$
^revdep$ ^revdep$
^appveyor\.yml$

8
DESCRIPTION

@ -4,7 +4,8 @@ Title: Extra Coordinate Systems, 'Geoms', Statistical Transformations, Scales
Version: 0.6.1 Version: 0.6.1
Maintainer: Bob Rudis <bob@rud.is> Maintainer: Bob Rudis <bob@rud.is>
Authors@R: c( Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")), person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
person("Ben", "Bolker", comment="Encircling & additional splines", role = c("aut", "ctb")), person("Ben", "Bolker", comment="Encircling & additional splines", role = c("aut", "ctb")),
person("Ben", "Marwick", comment="General codebase cleanup", role = c("ctb")), person("Ben", "Marwick", comment="General codebase cleanup", role = c("ctb")),
person("Jan", "Schulz", comment="Annotations", role = c("aut", "ctb")), person("Jan", "Schulz", comment="Annotations", role = c("aut", "ctb")),
@ -12,7 +13,8 @@ Authors@R: c(
person("ProPublica", role="dtc", comment="StateFace font"), person("ProPublica", role="dtc", comment="StateFace font"),
person("Aditya", "Kothari", role=c("aut", "ctb"), comment="Core functionality of horizon plots"), person("Aditya", "Kothari", role=c("aut", "ctb"), comment="Core functionality of horizon plots"),
person("Ather", role="dtc", comment="Core functionality of horizon plots"), person("Ather", role="dtc", comment="Core functionality of horizon plots"),
person("Jonathan","Sidi", role=c("aut","ctb"), comment="Annotation ticks") person("Jonathan","Sidi", role=c("aut","ctb"), comment="Annotation ticks"),
person("Tarcisio","Fedrizzi", role="ctb", comment="Bytes formatter")
) )
Description: A compendium of new geometries, coordinate systems, statistical Description: A compendium of new geometries, coordinate systems, statistical
transformations, scales and fonts for 'ggplot2', including splines, 1d and 2d densities, transformations, scales and fonts for 'ggplot2', including splines, 1d and 2d densities,
@ -41,6 +43,7 @@ Imports:
utils, utils,
graphics, graphics,
grDevices, grDevices,
plyr,
dplyr, dplyr,
RColorBrewer, RColorBrewer,
KernSmooth, KernSmooth,
@ -62,6 +65,7 @@ Collate:
'coord_proj.r' 'coord_proj.r'
'formatters.r' 'formatters.r'
'fortify.r' 'fortify.r'
'position-dodgev.R'
'geom2plotly.r' 'geom2plotly.r'
'geom_ash.r' 'geom_ash.r'
'geom_bkde.r' 'geom_bkde.r'

2
NAMESPACE

@ -23,6 +23,7 @@ export(GeomXSpline2)
export(GeomXspline) export(GeomXspline)
export(Kb) export(Kb)
export(Mb) export(Mb)
export(PositionDodgev)
export(StatAsh) export(StatAsh)
export(StatBkde) export(StatBkde)
export(StatBkde2d) export(StatBkde2d)
@ -46,6 +47,7 @@ export(geom_stateface)
export(geom_ubar) export(geom_ubar)
export(geom_xspline) export(geom_xspline)
export(load_stateface) export(load_stateface)
export(position_dodgev)
export(show_stateface) export(show_stateface)
export(stat_ash) export(stat_ash)
export(stat_bkde) export(stat_bkde)

2
NEWS.md

@ -1,6 +1,6 @@
0.5.0 0.5.0
===================== =====================
* `geom_ubar()` : unform bar charts based on `geom_segment()` * `geom_ubar()` : uniform bar charts based on `geom_segment()`
0.4.0 0.4.0
===================== =====================

87
R/formatters.r

@ -1,9 +1,9 @@
#' Bytes formatter: convert to byte measurement and display symbol. #' Bytes formatter: convert to byte measurement and display symbol.
#' #'
#' @return a function with three parameters, \code{x}, a numeric vector that #' @return a function with three parameters, \code{x}, a numeric vector that
#' returns a character vector, \code{symbol} the byte symbol (e.g. "\code{Kb}") #' returns a character vector, \code{symbol} a single or a vector of byte
#' desired and the measurement \code{units} (traditional \code{binary} or #' symbol(s) (e.g. "\code{Kb}") desired and the measurement \code{units}
#' \code{si} for ISI metric units). #' (traditional \code{binary} or \code{si} for ISI metric units).
#' @param x a numeric vector to format #' @param x a numeric vector to format
#' @param symbol byte symbol to use. If "\code{auto}" the symbol used will be #' @param symbol byte symbol to use. If "\code{auto}" the symbol used will be
#' determined by the maximum value of \code{x}. Valid symbols are #' determined by the maximum value of \code{x}. Valid symbols are
@ -12,6 +12,8 @@
#' equivalents and "\code{iB}" equivalents. #' equivalents and "\code{iB}" equivalents.
#' @param units which unit base to use, "\code{binary}" (1024 base) or #' @param units which unit base to use, "\code{binary}" (1024 base) or
#' "\code{si}" (1000 base) for ISI units. #' "\code{si}" (1000 base) for ISI units.
#' @param only_highest Whether to use the unit of the highest number or
#' each number uses its own unit.
#' @references Units of Information (Wikipedia) : #' @references Units of Information (Wikipedia) :
#' \url{http://en.wikipedia.org/wiki/Units_of_information} #' \url{http://en.wikipedia.org/wiki/Units_of_information}
#' @export #' @export
@ -21,8 +23,8 @@
#' Kb(sample(3000000000, 10)) #' Kb(sample(3000000000, 10))
#' Mb(sample(3000000000, 10)) #' Mb(sample(3000000000, 10))
#' Gb(sample(3000000000, 10)) #' Gb(sample(3000000000, 10))
byte_format <- function(symbol="auto", units="binary") { byte_format <- function (symbol = "auto", units = "binary", only_highest = TRUE) {
function(x) bytes(x, symbol, units) function(x) bytes(x, symbol, units, only_highest)
} }
#' @export #' @export
@ -39,47 +41,40 @@ Gb <- byte_format("Gb", "binary")
#' @export #' @export
#' @rdname byte_format #' @rdname byte_format
bytes <- function(x, symbol="auto", units=c("binary", "si")) { bytes <- function (x, symbol = "auto", units = c("binary", "si"),
only_highest = FALSE) {
symbol <- match.arg(symbol, c("auto", bin_names <- c("bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb")
"b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb", si_names <- c("bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB")
"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", units <- match.arg(units, c("binary", "si"))
"KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB")) valid_names <- c("auto", if (units == "binary") {
c(bin_names, toupper(bin_names))
units <- match.arg(units, c("binary", "si")) } else {
si_names
base <- switch(units, `binary`=1024, `si`=1000) })
symbol <- valid_names[pmatch(symbol, valid_names, duplicates.ok = TRUE)]
if (symbol == "auto") { if (any(is.na(symbol))) {
symbol <- stop(gettextf("Symbol must be one of %s", paste(dQuote(valid_names), collapse = ", ")))
if (max(x) >= (base^5)) { "Pb" }
else if (max(x) >= (base^4)) { "Tb" }
else if (max(x) >= (base^3)) { "Gb" }
else if (max(x) >= (base^2)) { "Kb" }
else if (max(x) >= (base^1)) { "Mb" }
else { "b" }
} }
base <- switch(units, binary = 1024, si = 1000)
out_names <- switch(units, binary = bin_names, si = si_names)
sym_len <- length(symbol)
inp_len <- length(x)
if (sym_len == 1) {
symbol <- rep(symbol, inp_len)
sym_len <- inp_len
}
if (sym_len != inp_len) {
stop("Symbols argument must be either long 1 or of the same length as the input vector.")
}
symbol <- ifelse(symbol == "auto",
pmax(floor(log(x, base)), 0),
match(tolower(symbol), tolower(out_names)) - 1)
if (only_highest) {
symbol <- max(symbol, na.rm = TRUE)
}
res <- paste(scales::comma(round(x / base^symbol, 1L)),
out_names[symbol + 1])
ifelse(!is.na(x), res, x)
}
switch(symbol,
"b" =, "B" = paste(x, "bytes"),
"Kb" =, "KB" = paste(scales::comma(round(x/(base^1), 1L)), "Kb"),
"Mb" =, "MB" = paste(scales::comma(round(x/(base^2), 1L)), "Mb"),
"Gb" =, "GB" = paste(scales::comma(round(x/(base^3), 1L)), "Gb"),
"Tb" =, "TB" = paste(scales::comma(round(x/(base^4), 1L)), "Tb"),
"Pb" =, "PB" = paste(scales::comma(round(x/(base^5), 1L)), "Pb"),
"Eb" =, "EB" = paste(scales::comma(round(x/(base^6), 1L)), "Eb"),
"Zb" =, "ZB" = paste(scales::comma(round(x/(base^7), 1L)), "Zb"),
"Yb" =, "YB" = paste(scales::comma(round(x/(base^8), 1L)), "Yb"),
"KiB" = paste(scales::comma(round(x/(base^1), 1L)), "KiB"),
"MiB" = paste(scales::comma(round(x/(base^2), 1L)), "MiB"),
"GiB" = paste(scales::comma(round(x/(base^3), 1L)), "GiB"),
"TiB" = paste(scales::comma(round(x/(base^4), 1L)), "TiB"),
"PiB" = paste(scales::comma(round(x/(base^5), 1L)), "PiB"),
"EiB" = paste(scales::comma(round(x/(base^6), 1L)), "EiB"),
"ZiB" = paste(scales::comma(round(x/(base^7), 1L)), "ZiB"),
"YiB" = paste(scales::comma(round(x/(base^8), 1L)), "YiB")
)
}

23
R/geom_dumbbell.R

@ -1,4 +1,4 @@
#' Dumbell charts #' Dumbbell charts
#' #'
#' The dumbbell geom is used to create dumbbell charts. #' The dumbbell geom is used to create dumbbell charts.
#' #'
@ -20,6 +20,8 @@
#' @param colour_xend the colour of the end point #' @param colour_xend the colour of the end point
#' @param dot_guide if \code{TRUE}, a leading dotted line will be placed before the left-most dumbbell point #' @param dot_guide if \code{TRUE}, a leading dotted line will be placed before the left-most dumbbell point
#' @param dot_guide_size,dot_guide_colour singe-value aesthetics for \code{dot_guide} #' @param dot_guide_size,dot_guide_colour singe-value aesthetics for \code{dot_guide}
#' @param position Position adjustment, either as a string, or the result of a
#' call to a position adjustment function.
#' @inheritParams ggplot2::layer #' @inheritParams ggplot2::layer
#' @export #' @export
#' @examples #' @examples
@ -34,19 +36,34 @@
#' labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") + #' labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
#' theme_minimal() + #' theme_minimal() +
#' theme(panel.grid.major.x=element_line(size=0.05)) #' theme(panel.grid.major.x=element_line(size=0.05))
#'
#' ## with vertical dodging
#' df2 <- data.frame(trt = c(LETTERS[1:5], "D"),
#' l = c(20, 40, 10, 30, 50, 40),
#' r = c(70, 50, 30, 60, 80, 70))
#'
#' ggplot(df2, aes(y=trt, x=l, xend=r)) +
#' geom_dumbbell(size=3, color="#e3e2e1",
#' colour_x = "#5b8124", colour_xend = "#bad744",
#' dot_guide=TRUE, dot_guide_size=0.25,
#' position=position_dodgev(height=0.4)) +
#' labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
#' theme_minimal() +
#' theme(panel.grid.major.x=element_line(size=0.05))
geom_dumbbell <- function(mapping = NULL, data = NULL, ..., geom_dumbbell <- function(mapping = NULL, data = NULL, ...,
colour_x = NULL, size_x = NULL, colour_x = NULL, size_x = NULL,
colour_xend = NULL, size_xend = NULL, colour_xend = NULL, size_xend = NULL,
dot_guide = FALSE, dot_guide_size = NULL, dot_guide = FALSE, dot_guide_size = NULL,
dot_guide_colour = NULL, dot_guide_colour = NULL,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) { na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
position = "identity") {
layer( layer(
data = data, data = data,
mapping = mapping, mapping = mapping,
stat = "identity", stat = "identity",
geom = GeomDumbbell, geom = GeomDumbbell,
position = "identity", position = position,
show.legend = show.legend, show.legend = show.legend,
inherit.aes = inherit.aes, inherit.aes = inherit.aes,
params = list( params = list(

3
R/geom_ubar.r

@ -5,9 +5,6 @@
#' constant without any tricks and you have granular control over the #' constant without any tricks and you have granular control over the
#' segment width. I decided it was time to make a `geom`. #' segment width. I decided it was time to make a `geom`.
#' #'
#' Dumbbell dot plots — dot plots with two or more series of data — are an
#' alternative to the clustered bar chart or slope graph.
#'
#' @md #' @md
#' @section Aesthetics: #' @section Aesthetics:
#' `geom_ubar`` understands the following aesthetics (required aesthetics are in bold): #' `geom_ubar`` understands the following aesthetics (required aesthetics are in bold):

14
R/geom_xspline.r

@ -132,11 +132,13 @@ geom_xspline <- function(mapping = NULL, data = NULL, stat = "xspline",
position = position, position = position,
show.legend = show.legend, show.legend = show.legend,
inherit.aes = inherit.aes, inherit.aes = inherit.aes,
params = list(spline_shape=spline_shape, params = list(
open=open, spline_shape = spline_shape,
na.rm = na.rm, open = open,
rep_ends=rep_ends, na.rm = na.rm,
...) rep_ends = rep_ends,
...
)
) )
} }
@ -188,6 +190,7 @@ StatXspline <- ggproto("StatXspline", Stat,
compute_group = function(self, data, scales, params, compute_group = function(self, data, scales, params,
spline_shape=-0.25, open=TRUE, rep_ends=TRUE) { spline_shape=-0.25, open=TRUE, rep_ends=TRUE) {
tf <- tempfile(fileext=".png") tf <- tempfile(fileext=".png")
png(tf) png(tf)
plot.new() plot.new()
@ -197,4 +200,5 @@ StatXspline <- ggproto("StatXspline", Stat,
data.frame(x=tmp$x, y=tmp$y) data.frame(x=tmp$x, y=tmp$y)
} }
) )

122
R/position-dodgev.R

@ -0,0 +1,122 @@
#' Vertically dodge position
#' @rdname position-dodgev
#' @author @@ggstance authors
#' @note position-dodgev(): unmodified from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
#' @export
position_dodgev <- function(height = NULL) {
ggplot2::ggproto(NULL, PositionDodgev, height = height)
}
#' @rdname position-dodgev
#' @author @@ggstance authors
#' @note PositionDodgev(): based on from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
#' @format NULL
#' @usage NULL
#' @export
PositionDodgev <- ggplot2::ggproto("PositionDodgev", ggplot2::Position,
required_aes = "y",
height = NULL,
setup_params = function(self, data) {
if (is.null(data$ymin) && is.null(data$ymax) && is.null(self$height)) {
warning("Height not defined. Set with `position_dodgev(height = ?)`",
call. = FALSE)
}
list(height = self$height)
},
compute_panel = function(data, params, scales) {
collidev(data, params$height, "position_dodgev", pos_dodgev, check.height = FALSE)
}
)
#' @rdname position-dodgev
#' @author @@ggstance authors
#' @note pos_dodgev(): unmodified from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
pos_dodgev <- function(df, height) {
n <- length(unique(df$group))
if (n == 1) return(df)
if (!all(c("ymin", "ymax") %in% names(df))) {
df$ymin <- df$y
df$ymax <- df$y
}
d_height <- max(df$ymax - df$ymin)
# df <- data.frame(n = c(2:5, 10, 26), div = c(4, 3, 2.666666, 2.5, 2.2, 2.1))
# ggplot(df, aes(n, div)) + geom_point()
# Have a new group index from 1 to number of groups.
# This might be needed if the group numbers in this set don't include all of 1:n
groupidx <- match(df$group, sort(unique(df$group)))
# Find the center for each group, then use that to calculate ymin and lmax
df$y <- df$y + height * ((groupidx - 0.5) / n - .5)
df$ymin <- df$y - d_height / n / 2
df$ymax <- df$y + d_height / n / 2
df
}
#' @rdname position-dodgev
#' @author @@ggstance authors
#' @note collidev(): based on lionel-/ggstance/R/position.R 73f521384ae8ea277db5f7d5a2854004aa18f947
collidev <- function(data, height = NULL, name, strategy, ..., check.height = TRUE, reverse = FALSE) {
# Determine height
if (!is.null(height)) {
# Width set manually
if (!(all(c("ymin", "ymax") %in% names(data)))) {
data$ymin <- data$y - height / 2
data$ymax <- data$y + height / 2
}
} else {
if (!(all(c("ymin", "ymax") %in% names(data)))) {
data$ymin <- data$y
data$ymax <- data$y
}
# Width determined from data, must be floating point constant
heights <- unique(data$ymax - data$ymin)
heights <- heights[!is.na(heights)]
# # Suppress warning message since it's not reliable
# if (!zero_range(range(heights))) {
# warning(name, " requires constant height: output may be incorrect",
# call. = FALSE)
# }
height <- heights[1]
}
# Reorder by x position, then on group. The default stacking order reverses
# the group in order to match the legend order.
if (reverse) {
data <- data[order(data$ymin, data$group), ]
} else {
data <- data[order(data$ymin, -data$group), ]
}
# Check for overlap
intervals <- as.numeric(t(unique(data[c("ymin", "ymax")])))
intervals <- intervals[!is.na(intervals)]
if (length(unique(intervals)) > 1 & any(diff(scale(intervals)) < -1e-6)) {
warning(name, " requires non-overlapping y intervals", call. = FALSE)
# This is where the algorithm from [L. Wilkinson. Dot plots.
# The American Statistician, 1999.] should be used
}
data$group <- seq_len(nrow(data)) ## reset grouping
if (!is.null(data$xmax)) {
plyr::ddply(data, "ymin", strategy, ..., height = height)
} else if (!is.null(data$x)) {
data$xmax <- data$x
data <- plyr::ddply(data, "ymin", strategy, ..., height = height)
data$x <- data$xmax
data$yend <- data$y ## ALLOW FOR A YEND COLUMN
data
} else {
stop("Neither x nor xmax defined")
}
}

4
R/stat-stepribbon.r

@ -5,9 +5,9 @@
#' @md #' @md
#' @inheritParams ggplot2::geom_ribbon #' @inheritParams ggplot2::geom_ribbon
#' @param geom which geom to use; defaults to "`ribbon`" #' @param geom which geom to use; defaults to "`ribbon`"
#' @param direction \code{hv} for horizontal-veritcal steps, `vh`` for #' @param direction `hv` for horizontal-veritcal steps, `vh` for
#' vertical-horizontal steps #' vertical-horizontal steps
#' @references \url{https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/9cFWHaH1CPs} #' @references [https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/9cFWHaH1CPs]()
#' @export #' @export
#' @examples #' @examples
#' x <- 1:10 #' x <- 1:10

2
R/stateface.r

@ -48,7 +48,7 @@ load_stateface <- function() {
system.file("fonts/", package="ggalt"), system.file("fonts/", package="ggalt"),
prompt=FALSE, pattern="*.ttf", recursive=FALSE))) prompt=FALSE, pattern="*.ttf", recursive=FALSE)))
} }
tmp <- capture.output(suppressWarnings(extrafont::loadfonts(quiet=TRUE))) tmp <- utils::capture.output(suppressWarnings(extrafont::loadfonts(quiet=TRUE)))
} }
#' Use ProPublica's StateFace font in ggplot2 plots #' Use ProPublica's StateFace font in ggplot2 plots

6
README.Rmd

@ -10,6 +10,7 @@ knitr::opts_chunk$set(collapse=TRUE, comment="##", fig.retina=2, fig.path = "REA
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active) [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/ggalt.svg?branch=master)](https://travis-ci.org/hrbrmstr/ggalt) [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/ggalt.svg?branch=master)](https://travis-ci.org/hrbrmstr/ggalt)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/ggalt?branch=master&svg=true)](https://ci.appveyor.com/project/hrbrmstr/ggalt)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggalt)](https://CRAN.R-project.org/package=ggalt) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggalt)](https://CRAN.R-project.org/package=ggalt)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ggalt) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ggalt)
@ -25,8 +26,9 @@ The following functions are implemented:
- `geom_xspline` : Connect control points/observations with an X-spline - `geom_xspline` : Connect control points/observations with an X-spline
- `stat_xspline` : Connect control points/observations with an X-spline - `stat_xspline` : Connect control points/observations with an X-spline
- `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
- `geom_stateface`: Use ProPublica's StateFace font in ggplot2 plots- `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `geom_stateface`: Use ProPublica's StateFace font in ggplot2 plots
- `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_ash` : Compute and display a univariate averaged shifted histogram (polynomial kernel) (uses `ash::ash1`/`ash::bin1`) - `stat_ash` : Compute and display a univariate averaged shifted histogram (polynomial kernel) (uses `ash::ash1`/`ash::bin1`)
- `geom_encircle`: Automatically enclose points in a polygon - `geom_encircle`: Automatically enclose points in a polygon

11
README.md

@ -6,6 +6,8 @@ state and is being actively
developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active) developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![Travis-CI Build [![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/ggalt.svg?branch=master)](https://travis-ci.org/hrbrmstr/ggalt) Status](https://travis-ci.org/hrbrmstr/ggalt.svg?branch=master)](https://travis-ci.org/hrbrmstr/ggalt)
[![AppVeyor Build
Status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/ggalt?branch=master&svg=true)](https://ci.appveyor.com/project/hrbrmstr/ggalt)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/ggalt)](https://CRAN.R-project.org/package=ggalt) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/ggalt)](https://CRAN.R-project.org/package=ggalt)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ggalt) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/ggalt)
@ -36,13 +38,14 @@ The following functions are implemented:
- `geom_bkde` : Display a smooth density estimate (uses - `geom_bkde` : Display a smooth density estimate (uses
`KernSmooth::bkde`) `KernSmooth::bkde`)
- `geom_stateface`: Use ProPublica’s StateFace font in ggplot2 plots- - `geom_stateface`: Use ProPublica’s StateFace font in ggplot2 plots
`stat_bkde` : Display a smooth density estimate (uses
`KernSmooth::bkde`)
- `geom_bkde2d` : Contours from a 2d density estimate. (uses - `geom_bkde2d` : Contours from a 2d density estimate. (uses
`KernSmooth::bkde2D`) `KernSmooth::bkde2D`)
- `stat_bkde` : Display a smooth density estimate (uses
`KernSmooth::bkde`)
- `stat_bkde2d` : Contours from a 2d density estimate. (uses - `stat_bkde2d` : Contours from a 2d density estimate. (uses
`KernSmooth::bkde2D`) `KernSmooth::bkde2D`)
@ -86,7 +89,7 @@ library(ggalt)
# current verison # current verison
packageVersion("ggalt") packageVersion("ggalt")
## [1] '0.5.0' ## [1] '0.6.1'
set.seed(1492) set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10), dat <- data.frame(x=c(1:10, 1:10, 1:10),

45
appveyor.yml

@ -0,0 +1,45 @@
# DO NOT CHANGE the "init" and "install" sections below
# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:
ps: Bootstrap
cache:
- C:\RLibrary
# Adapt as necessary starting from here
build_script:
- travis-tool.sh install_deps
test_script:
- travis-tool.sh run_tests
on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs
- path: '*.Rcheck\**\*.out'
name: Logs
- path: '*.Rcheck\**\*.fail'
name: Logs
- path: '*.Rcheck\**\*.Rout'
name: Logs
- path: '\*_*.tar.gz'
name: Bits
- path: '\*_*.zip'
name: Bits

13
man/byte_format.Rd

@ -8,7 +8,7 @@
\alias{bytes} \alias{bytes}
\title{Bytes formatter: convert to byte measurement and display symbol.} \title{Bytes formatter: convert to byte measurement and display symbol.}
\usage{ \usage{
byte_format(symbol = "auto", units = "binary") byte_format(symbol = "auto", units = "binary", only_highest = TRUE)
Kb(x) Kb(x)
@ -16,7 +16,7 @@ Mb(x)
Gb(x) Gb(x)
bytes(x, symbol = "auto", units = c("binary", "si")) bytes(x, symbol = "auto", units = c("binary", "si"), only_highest = FALSE)
} }
\arguments{ \arguments{
\item{symbol}{byte symbol to use. If "\code{auto}" the symbol used will be \item{symbol}{byte symbol to use. If "\code{auto}" the symbol used will be
@ -28,13 +28,16 @@ equivalents and "\code{iB}" equivalents.}
\item{units}{which unit base to use, "\code{binary}" (1024 base) or \item{units}{which unit base to use, "\code{binary}" (1024 base) or
"\code{si}" (1000 base) for ISI units.} "\code{si}" (1000 base) for ISI units.}
\item{only_highest}{Whether to use the unit of the highest number or
each number uses its own unit.}
\item{x}{a numeric vector to format} \item{x}{a numeric vector to format}
} }
\value{ \value{
a function with three parameters, \code{x}, a numeric vector that a function with three parameters, \code{x}, a numeric vector that
returns a character vector, \code{symbol} the byte symbol (e.g. "\code{Kb}") returns a character vector, \code{symbol} a single or a vector of byte
desired and the measurement \code{units} (traditional \code{binary} or symbol(s) (e.g. "\code{Kb}") desired and the measurement \code{units}
\code{si} for ISI metric units). (traditional \code{binary} or \code{si} for ISI metric units).
} }
\description{ \description{
Bytes formatter: convert to byte measurement and display symbol. Bytes formatter: convert to byte measurement and display symbol.

22
man/geom_dumbbell.Rd

@ -2,12 +2,13 @@
% Please edit documentation in R/geom_dumbbell.R % Please edit documentation in R/geom_dumbbell.R
\name{geom_dumbbell} \name{geom_dumbbell}
\alias{geom_dumbbell} \alias{geom_dumbbell}
\title{Dumbell charts} \title{Dumbbell charts}
\usage{ \usage{
geom_dumbbell(mapping = NULL, data = NULL, ..., colour_x = NULL, geom_dumbbell(mapping = NULL, data = NULL, ..., colour_x = NULL,
size_x = NULL, colour_xend = NULL, size_xend = NULL, size_x = NULL, colour_xend = NULL, size_xend = NULL,
dot_guide = FALSE, dot_guide_size = NULL, dot_guide_colour = NULL, dot_guide = FALSE, dot_guide_size = NULL, dot_guide_colour = NULL,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
position = "identity")
} }
\arguments{ \arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or \item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
@ -59,6 +60,9 @@ display.}
rather than combining with them. This is most useful for helper functions rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.} the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
\item{position}{Position adjustment, either as a string, or the result of a
call to a position adjustment function.}
} }
\description{ \description{
The dumbbell geom is used to create dumbbell charts. The dumbbell geom is used to create dumbbell charts.
@ -84,4 +88,18 @@ ggplot(df, aes(y=trt, x=l, xend=r)) +
labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") + labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
theme_minimal() + theme_minimal() +
theme(panel.grid.major.x=element_line(size=0.05)) theme(panel.grid.major.x=element_line(size=0.05))
## with vertical dodging
df2 <- data.frame(trt = c(LETTERS[1:5], "D"),
l = c(20, 40, 10, 30, 50, 40),
r = c(70, 50, 30, 60, 80, 70))
ggplot(df2, aes(y=trt, x=l, xend=r)) +
geom_dumbbell(size=3, color="#e3e2e1",
colour_x = "#5b8124", colour_xend = "#bad744",
dot_guide=TRUE, dot_guide_size=0.25,
position=position_dodgev(height=0.4)) +
labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
theme_minimal() +
theme(panel.grid.major.x=element_line(size=0.05))
} }

3
man/geom_spikelines.Rd

@ -80,3 +80,6 @@ ggrepel::geom_label_repel(data = mtcars[mtcars$carb==4,],aes(label = name))
} }
} }
\author{
Jonathan Sidi
}

4
man/geom_ubar.Rd

@ -59,10 +59,6 @@ I've been using \code{geom_segment} more to make "bar" charts, setting
constant without any tricks and you have granular control over the constant without any tricks and you have granular control over the
segment width. I decided it was time to make a \code{geom}. segment width. I decided it was time to make a \code{geom}.
} }
\details{
Dumbbell dot plots — dot plots with two or more series of data — are an
alternative to the clustered bar chart or slope graph.
}
\section{Aesthetics}{ \section{Aesthetics}{
`geom_ubar`` understands the following aesthetics (required aesthetics are in bold): `geom_ubar`` understands the following aesthetics (required aesthetics are in bold):

39
man/position-dodgev.Rd

@ -0,0 +1,39 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/position-dodgev.R
\docType{data}
\name{position_dodgev}
\alias{position_dodgev}
\alias{PositionDodgev}
\alias{pos_dodgev}
\alias{collidev}
\title{Vertically dodge position}
\usage{
position_dodgev(height = NULL)
pos_dodgev(df, height)
collidev(data, height = NULL, name, strategy, ..., check.height = TRUE,
reverse = FALSE)
}
\description{
Vertically dodge position
}
\note{
position-dodgev(): unmodified from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
PositionDodgev(): based on from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
pos_dodgev(): unmodified from lionel-/ggstance/R/position-dodgev.R 73f521384ae8ea277db5f7d5a2854004aa18f947
collidev(): based on lionel-/ggstance/R/position.R 73f521384ae8ea277db5f7d5a2854004aa18f947
}
\author{
@ggstance authors
@ggstance authors
@ggstance authors
@ggstance authors
}
\keyword{datasets}

2
man/stat_stepribbon.Rd

@ -47,7 +47,7 @@ rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.} the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
\item{direction}{\code{hv} for horizontal-veritcal steps, `vh`` for \item{direction}{\code{hv} for horizontal-veritcal steps, \code{vh} for
vertical-horizontal steps} vertical-horizontal steps}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are \item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are

18
vignettes/ggalt_examples.Rmd

@ -263,3 +263,21 @@ ggplot(df, aes(y=trt, x=l, xend=r)) +
theme(panel.grid.major.x=element_line(size=0.05)) + theme(panel.grid.major.x=element_line(size=0.05)) +
theme(panel.grid.major.y=element_blank()) theme(panel.grid.major.y=element_blank())
``` ```
with optional vertical dodging
```{r dumbbellv, message=FALSE, fig.width=7, fig.height=2.5}
df2 <- data.frame(trt = c(LETTERS[1:5], "D"),
l = c(20, 40, 10, 30, 50, 40),
r = c(70, 50, 30, 60, 80, 70))
ggplot(df2, aes(y=trt, x=l, xend=r)) +
geom_dumbbell(size=3, color="#e3e2e1",
colour_x = "#5b8124", colour_xend = "#bad744",
dot_guide=TRUE, dot_guide_size=0.25,
position=position_dodgev(height=0.8)) +
labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
theme_minimal() +
theme(panel.grid.major.x=element_line(size=0.05))
```

Loading…
Cancel
Save