Skip to content

Instantly share code, notes, and snippets.

View meyera's full-sized avatar

Alexander Meyer meyera

View GitHub Profile
@hrbrmstr
hrbrmstr / viridis_scales.R
Created July 19, 2015 18:45
viridis color/fill scales for ggplot2
viridis_pal <- function(alpha=1) {
function(n) {
viridis(n, alpha)
}
}
scale_color_viridis <- function(..., alpha=1, discrete=TRUE) {
if (discrete) {
discrete_scale("colour", "viridis", viridis_pal(alpha), ...)
#' ---
#' output:
#' html_document:
#' keep_md: TRUE
#' ---
#+ include = FALSE
library(dplyr)
#' Responses to [my
## Curated stuff:
## * MetaCran: http://www.r-pkg.org/
## * List of Packages gathered by Garret G.: https://github.com/rstudio/RStartHere
## * List of popular packages https://awesome-r.com/
## * List of DataScience R tutorials https://github.com/ujjwalkarn/DataScienceR
## * List of machine elearning tutorials by subject: https://ujjwalkarn.github.io/Machine-Learning-Tutorials/
## Reproducible package management for R:
install.packages("devtools")
install.packages("tidyverse")
@araastat
araastat / ggkm.R
Last active July 6, 2018 17:39
Plotting a Kaplan-Meier curve using ggplot. ggkmTable.R adds a table below the plot showing numbers at risk at different times.
#’ Create a Kaplan-Meier plot using ggplot2
#’
#’ @param sfit a \code{\link[survival]{survfit}} object
#’ @param returns logical: if \code{TRUE}, return an ggplot object
#’ @param xlabs x-axis label
#’ @param ylabs y-axis label
#’ @param ystratalabs The strata labels. \code{Default = levels(summary(sfit)$strata)}
#’ @param ystrataname The legend name. Default = “Strata”
#’ @param timeby numeric: control the granularity along the time-axis
#’ @param main plot title