Cheatsheets
Cheetsheets including for:
ggplot
extensions and packages
All Your Figure Are Belong To Us ggplot2 extensions - gallery
bbplotBBC Visual and Data Journalism cookbook for R graphicscowplotStreamlined Plot Theme and Plot Annotations for ‘ggplot2’directlabelsEasily add direct labels to plots using the directlabels packageGGallyExtendsggplot2by adding several functions to reduce the complexity of combining geometric objects with transformed datagganimateA Grammar of Animated GraphicsggforceAcceleratingggplot2gggraphAn Implementation of Grammar of Graphics for Graphs and NetworksgghighlightHighlight Lines and Points inggplot2ggnetworkGeometries to Plot Networks withggplot2ggnewscaleMultiple Fill and Color Scales in ‘ggplot2’ggpubrggplot2Based Publication Ready PlotsggrepelAutomatically Position Non-Overlapping Text Labels with ‘ggplot2’ggparliamentParliament PlotsggspatialSpatial Data Framework forggplot2ghibliStudio Ghibli Colour PalettesgovstyleA package for applying a gov.uk style to plots created in the R packageggplot2vdiffrVisual Regression Testing and Graphical Diffing
tips
check_overlap = TRUEused to prevent labels from overlapping- end definitions with
NULLto make it easier to comment intermediate steps - ggplotline telling a story with labels, colors, and layout
- Hyperlinking text in a
ggplot2visualization
tidyverse tips
dplyr related
extractto parse a substring into a variablefct_lumpwithingroup_bystatementglimpseinstead ofstrto view data in rowsgroup_splitsplit data frame by groupsjanitorpackage for basic cleaningwidyrpackage 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
broomConvert Statistical Analysis Objects into Tidy TibblescorrrCorrelations in RgamGeneralized Additive Modelslfe::felm()Fit a linear model with multiple group fixed effectslimeLocal Interpretable Model-Agnostic ExplanationsmgcvMixed GAM Computation Vehicle with Automatic Smoothness EstimationparsnipA Common API to Modeling and Analysis Functions- Some R Packages for ROC Curves
smurfSparse Multi-Type Regularized Feature ModelingtidybayesTidy Data and ‘Geoms’ for Bayesian ModelstidyloTidy log odds ratio weighted by uninformative priortidymodelsEasily Install and Load the ‘Tidymodels’ PackagestidypredictRun Predictions Inside the Databasetidyrocxgboostoptimizes splits based upon the objective function (which has a default loss function), e.g.reg:linear–> squared errorxgboostExplainerAn R package that makesxgboostmodels fully interpretable
Other packages of note
beeprEasily Play Notification Sounds on any PlatformfunneljoinJoin tables based on events occurring in sequence in a funnelfuturesUnified Parallel and Distributed Processing in R for EveryonelobstrVisualize R Data Structures with TreesloonInteractive Statistical Data VisualizationredocReversible Reproducible DocumentsrecipesPreprocessing Tools to Create Design MatricestidygraphA Tidy API for Graph ManipulationtidylogLogging for ‘dplyr’ FunctionsvroomThe 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