Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64c02e2
commit c1d78ab
Showing
12 changed files
with
189 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
Package: utile.visuals | ||
Title: Create Visuals for Publication | ||
Version: 0.2.0 | ||
Version: 0.2.1 | ||
Authors@R: c(person('Eric', 'Finnesgard', email = 'finnesgard.eric@mayo.edu', role = c('aut', 'cre'))) | ||
Description: A small set of functions for making visuals for publication in 'ggplot2'. Key functions include geom_stepconfint() for drawing a step confidence interval on a Kaplan-Meier curve and theme_white()/theme_black() which are minimalist 'ggplot2' themes with transparent backgrounds. | ||
License: LGPL (>= 2) | ||
Encoding: UTF-8 | ||
LazyData: TRUE | ||
Depends: R (>= 3.4.0) | ||
Imports: ggplot2, purrr, utile.tools (>= 0.2.0), gridExtra | ||
Imports: ggplot2, purrr, utile.tools (>= 0.2.0), gridExtra, dplyr | ||
Suggests: survival, broom, grid | ||
RoxygenNote: 6.1.1 | ||
NeedsCompilation: no | ||
Packaged: 2019-07-11 02:26:07 UTC; m130239 | ||
Packaged: 2019-09-20 14:48:14 UTC; m130239 | ||
Author: Eric Finnesgard [aut, cre] | ||
Maintainer: Eric Finnesgard <finnesgard.eric@mayo.edu> | ||
Repository: CRAN | ||
Date/Publication: 2019-07-11 04:22:59 UTC | ||
Date/Publication: 2019-09-20 15:10:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
utils::globalVariables(c('strata', 'n.risk')) | ||
|
||
#' @title Connect tidy'd survival::survfit data to the origin of a plot | ||
#' @description Occasionally when tidy'd survfit data is graphed in ggplot2::geom_step(), | ||
#' the KM curve will not connect with the origin of the plot. This tool appends data | ||
#' connecting the lines to the origin. | ||
#' @param data Required. tibble::tibble() object. survival::survfit data that has been | ||
#' tidy'd with broom::tidy(). | ||
#' @return A tibble containing the original data with appended points that connect the | ||
#' curve with to the plot origin. | ||
#' @note Adapted from an unexported function called .connect2origin() in the survminer | ||
#' package created by Alboukadel Kassambara. | ||
#' @examples | ||
#' library(survival) | ||
#' library(broom) # tidy() model data | ||
#' | ||
#' # Data with group names specified | ||
#' data_diabetic <- diabetic | ||
#' data_diabetic$trt <- as.factor(data_diabetic$trt) | ||
#' levels(data_diabetic$trt) <- c('None', 'Laser') | ||
#' | ||
#' # Survival Model | ||
#' fit <- survfit(Surv(time, status) ~ trt, data = data_diabetic) | ||
#' fit_data <- tidy(fit) | ||
#' | ||
#' connect_origin(fit_data) | ||
#' @export | ||
connect_origin <- function (data) { | ||
if ('n.risk' %in% colnames(data)) data <- dplyr::arrange(.data = data, dplyr::desc(n.risk)) | ||
origin <- dplyr::distinct(.data = data, strata, .keep_all = TRUE) | ||
origin[intersect(c('time', 'n.censor', 'std.error', "n.event"), colnames(origin))] <- 0 | ||
origin[c('estimate', 'conf.high', 'conf.low')] <- 1.0 | ||
dplyr::bind_rows(origin, data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
# The `utile.visuals` package | ||
# utile.visuals | ||
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/utile.visuals)](https://CRAN.R-project.org/package=utile.visuals) | ||
[![Total Downloads](https://cranlogs.r-pkg.org/badges/grand-total/utile.visuals)](https://CRAN.R-project.org/package=utile.visuals) | ||
|
||
## Overview | ||
A small set of functions for making visuals for publication in ggplot2. Key functions include geom_stepconfint() for drawing a step confidence interval on a ggplot2 KM curve and theme_white()/theme_black() which are minimalist ggplot2 themes with transparent backgrounds. | ||
A small set of functions for making visuals for publication in ggplot2. Key functions include `geom_stepconfint()` for drawing a step confidence interval on a ggplot2 KM curve and `theme_white()`/`theme_black()` which are minimalist ggplot2 themes with transparent backgrounds. | ||
|
||
## The `gg` Functions | ||
- **ggrisktable()**: A simple wrapper function which calculates the numbers at risk for a survival model and a given set of time points then creates a ggplot2 table with them. | ||
## Functions | ||
### > gg | ||
- `ggrisktable()`: A simple wrapper function which calculates the numbers at risk for a survival model and a given set of time points then creates a ggplot2 table with them. | ||
|
||
## The `geom_` Functions | ||
- **geom_stepconfint()**: Produces a step function confidence interval for survival curves. Essentially the geom_step() for confidence intervals which ggplot2 elects not to provide. | ||
### > geom_ | ||
- `geom_stepconfint()`: Produces a step function confidence interval for survival curves. Essentially the `ggplot2::geom_step()` for confidence intervals which ggplot2 elects not to provide. | ||
|
||
## The `theme_` Functions: | ||
- **theme_white()**: A ggplot2 theme which removes most background elements and makes all text/lines white. | ||
- **theme_black()**: A ggplot2 theme which removes most background elements and makes all text/lines black. | ||
- **theme_risk_white()**: Minimalist ggplot2 theme which removes most background elements and makes all text/lines white. | ||
- **theme_risk_black()**: Minimalist ggplot2 theme which removes most background elements and makes all text/lines black. | ||
### > theme_ | ||
- `theme_white()`: A ggplot2 theme which removes most background elements and makes all text/lines white. | ||
- `theme_black()`: A ggplot2 theme which removes most background elements and makes all text/lines black. | ||
- `theme_risk_white()`: Minimalist ggplot2 theme which removes most background elements and makes all text/lines white. | ||
- `theme_risk_black()`: Minimalist ggplot2 theme which removes most background elements and makes all text/lines black. | ||
|
||
### > append_ | ||
- `append_table()`: Aligns axes and combines a ggplot2 plot and table into a single plot. Can handle legends. | ||
|
||
### > connect_ | ||
- `connect_origin()`: Connects tidy'd survival::survfit data to the origin of a plot. | ||
|
||
## The `append_table` Functions | ||
- **append_table()**: Aligns axes and combines a ggplot2 plot and table into a single plot. Can handle legends. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.