Browse Source
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.Rdpull/50/head
yoni sidi
6 years ago
21 changed files with 351 additions and 85 deletions
@ -1,10 +1,8 @@ |
|||
^.*\.Rproj$ |
|||
^\.Rproj\.user$ |
|||
^README\.Rmd$ |
|||
^README-.*\.png$ |
|||
^README.*$ |
|||
^\.travis\.yml$ |
|||
^CONDUCT\.md$ |
|||
^README_figs |
|||
^README\.html$ |
|||
^cran-comments\.md$ |
|||
^revdep$ |
|||
^appveyor\.yml$ |
|||
|
@ -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") |
|||
} |
|||
} |
@ -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 |
@ -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} |
Loading…
Reference in new issue