R Programming Cheat Sheet
R Programming Cheat Sheet
Data Types
┣ Numeric : Real or decimal numbers
Basic Operations
┣ x + y : Addition
┣ x - y : Subtraction
┣ x * y : Multiplication
┣ x / y : Division
┣ x ^ y : Exponentiation
┣ which(data > value) : Find the indices of values that meet a condition
┣ library(lubridate) : Load the lubridate package for working with dates and
times
┣ ggvis(data, ~x, ~y) %>% layer_*(...) %>% ... : Create an interactive plot
using ggvis
Control Structures
┣ if (condition) {expression} : Execute an expression if a condition is true
┣ library(haven) : Load the haven package for SPSS, SAS, and Stata files
Graphics
┣ library(ggplot2) : Load the ggplot2 package
Machine Learning
┣ library(caret) : Load the caret package for machine learning
Web Scraping
┣ library(rvest) : Load the rvest package for web scraping
┣ library(zoo) : Load the zoo package for working with time series
┣ Applied Time Series Analysis with R by Wayne A. Woodward and Henry L. Gray
Useful Packages
┣ dplyr : Data manipulation
┣ CRAN : https://cran.r-project.org/
┣ R-bloggers : https://www.r-bloggers.com/
┗ DataCamp : https://www.datacamp.com/
┣ Advanced R: https://adv-r.hadley.nz/
Keyboard Shortcuts
┣ Ctrl+Enter : Run current line or selection