Cheatsheets
Cheetsheets including for:
ggplot
extensions and packages
All Your Figure Are Belong To Us ggplot2 extensions - gallery
bbplot
BBC Visual and Data Journalism cookbook for R graphicscowplot
Streamlined Plot Theme and Plot Annotations for ‘ggplot2’directlabels
Easily add direct labels to plots using the directlabels packageGGally
Extendsggplot2
by adding several functions to reduce the complexity of combining geometric objects with transformed datagganimate
A Grammar of Animated Graphicsggforce
Acceleratingggplot2
gggraph
An Implementation of Grammar of Graphics for Graphs and Networksgghighlight
Highlight Lines and Points inggplot2
ggnetwork
Geometries to Plot Networks withggplot2
ggnewscale
Multiple Fill and Color Scales in ‘ggplot2’ggpubr
ggplot2
Based Publication Ready Plotsggrepel
Automatically Position Non-Overlapping Text Labels with ‘ggplot2’ggparliament
Parliament Plotsggspatial
Spatial Data Framework forggplot2
ghibli
Studio Ghibli Colour Palettesgovstyle
A package for applying a gov.uk style to plots created in the R packageggplot2
vdiffr
Visual Regression Testing and Graphical Diffing
tips
check_overlap = TRUE
used to prevent labels from overlapping- end definitions with
NULL
to make it easier to comment intermediate steps - ggplotline telling a story with labels, colors, and layout
- Hyperlinking text in a
ggplot2
visualization
tidyverse tips
dplyr
related
extract
to parse a substring into a variablefct_lump
withingroup_by
statementglimpse
instead ofstr
to view data in rowsgroup_split
split data frame by groupsjanitor
package for basic cleaningwidyr
package to widen data, e.g. for forming pairwise comparisons
Other tips
- end
magrittr
%>%
pipes withidentity()
to make it easier to comment intermediate steps
Modelling
GLM helpers
Modelling packages
broom
Convert Statistical Analysis Objects into Tidy Tibblescorrr
Correlations in Rgam
Generalized Additive Modelslfe::felm()
Fit a linear model with multiple group fixed effectslime
Local Interpretable Model-Agnostic Explanationsmgcv
Mixed GAM Computation Vehicle with Automatic Smoothness Estimationparsnip
A Common API to Modeling and Analysis Functions- Some R Packages for ROC Curves
smurf
Sparse Multi-Type Regularized Feature Modelingtidybayes
Tidy Data and ‘Geoms’ for Bayesian Modelstidylo
Tidy log odds ratio weighted by uninformative priortidymodels
Easily Install and Load the ‘Tidymodels’ Packagestidypredict
Run Predictions Inside the Databasetidyroc
xgboost
optimizes splits based upon the objective function (which has a default loss function), e.g.reg:linear
–> squared errorxgboostExplainer
An R package that makesxgboost
models fully interpretable
Other packages of note
beepr
Easily Play Notification Sounds on any Platformfunneljoin
Join tables based on events occurring in sequence in a funnelfutures
Unified Parallel and Distributed Processing in R for Everyonelobstr
Visualize R Data Structures with Treesloon
Interactive Statistical Data Visualizationredoc
Reversible Reproducible Documentsrecipes
Preprocessing Tools to Create Design Matricestidygraph
A Tidy API for Graph Manipulationtidylog
Logging for ‘dplyr’ Functionsvroom
The fastest delimited reader for R
Useful commands
General
clip(object_name) # copy an object to clipboard
do.call("function name") # constructs and executes a function call from a name or a function and a list of arguments to be passed to it
get("object name") # Return the Value of a Named Object
rm(list = ls()) # clear objects from workspace
readRDS() / saveRDS() # Functions to write a single R object to a file, and to restore it
View() # Invoke a spreadsheet-style data viewer on a matrix-like R object
%T>% # Pipe a value forward into a function- or call expression and return the original value instead of the result. This is useful when an expression is used for its side-effect, say plotting or printing.
- Efficient R Programming
- Fix leaky pipes in R
- Piping - end chains with
identity()
to allow commenting of the last step without errors
Benchmarking
ptm <- proc.time() # Initiate a timer
proc.time() - ptm # Stop the timer
system.time() # time a particular command
# alternative library
library("rbenchmark")
Memory usage
source: Advanced R - Memory
library(pryr)
tracemem() # memory address
mem_used() # memory usage of an object
mem_change() # memory change from a command
Other references
Excel
- Contextures Blog Excel Tips and Tutorials
- ExcelIsFun on YouTube
- MrExcel on YouTube
- Peltier Tech Blog
- Tushar Mehta
Blogs
- David Robinson Tidy Tuesday screencast for the weekly Tidy Tuesday social data project
- Eddie’s Math and Calculator Blog
- FiveThirtyEight | Our data
- No Free Hunch | The Official Blog of Kaggle.com
- R-bloggers
- R Studio Blog
- R Views | An R community blog edited by RStudio
- R Weekly
- Revolutions
References
- Assessing data analysis and programming
- An Introduction to Statistical Learning
- blogdown: Creating Websites with R Markdown
- Code Complete, Second Edition
- Elements and Principles of Data Analysis
- The Elements of Statistical Learning
- Happy Git and GitHub for the useR
- Hypothesis tests
- In-depth introduction to machine learning in 15 hours of expert videos
- Reproducible Environments
- Scientists rise up against statistical significance