Skip to content

Instantly share code, notes, and snippets.

View meyera's full-sized avatar

Alexander Meyer meyera

  • Berlin Heart Center - Cardiac Surgery
  • Berlin, Germany
View GitHub Profile
@meyera
meyera / roc_auc_tidy.R
Created December 3, 2016 18:08
ROC plot and AUC calculation the tidy way - by David Robinson (@drob) tweeted at 5:22 PM on Tue, Nov 29, 2016: Using tidyverse tools to calculate AUC and plot ROC curves #rstats https://t.co/BYJcKXJwoe (https://twitter.com/drob/status/803635156841943040?s=03)
library(tidyverse)
theme_set(theme_minimal())
roc <- iris %>%
gather(Metric, Value, -Species) %>%
mutate(Positive = Species == "virginica") %>%
group_by(Metric, Value) %>%
summarise(Positive = sum(Positive),
Negative = n() - sum(Positive)) %>%
arrange(-Value) %>%
@meyera
meyera / viridis_scales.R
Created July 12, 2016 07:14 — forked from hrbrmstr/viridis_scales.R
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), ...)
@meyera
meyera / CreateRadialPlot.R
Last active November 8, 2015 21:04
A radar plot function for visualising Cluster Profiles. Found at: http://rstudio-pubs-static.s3.amazonaws.com/5795_e6e6411731bb4f1b9cc7eb49499c2082.html
# Input data
# plot.data - dataframe comprising one row per group (cluster); col1 = group name; cols 2-n = variable values
# axis.labels - names of axis labels if other than column names supplied via plot.data [Default = colnames(plot.data)[-1]
#
# Grid lines
# grid.min - value at which mininum grid line is plotted [Default = -0.5]
# grid.mid - value at which 'average' grid line is plotted [Default = 0]
# grid.max - value at which 'average' grid line is plotted [Default = 0.5]
#
# Plot centre
#' ---
#' output:
#' html_document:
#' keep_md: TRUE
#' ---
#+ include = FALSE
library(dplyr)
#' Responses to [my
#!/usr/bin/env r
#
# a simple example to update packages in /usr/local/lib/R/site-library
# parameters are easily adjustable
repos <- "http://cran.rstudio.com"
lib.loc <- "/usr/local/lib/R/site-library"
update.packages(repos=repos, ask=FALSE, lib.loc=lib.loc)
## 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")