Catalog / R Programming Language Cheatsheet
R Programming Language Cheatsheet
A comprehensive cheat sheet for the R programming language, covering data structures, syntax, data manipulation, statistical analysis, and common functions.
Data Structures
Vectors
Definition |
A one-dimensional array of elements of the same data type. |
Creating Vectors |
|
Accessing Elements |
|
Common Functions |
|
Example |
|
Matrices
Definition |
A two-dimensional array of elements of the same data type. |
Creating Matrices |
|
Accessing Elements |
|
Common Functions |
|
Example |
|
Lists
Definition |
An ordered collection of elements, which can be of different data types. |
Creating Lists |
|
Accessing Elements |
|
Common Functions |
|
Example |
|
Data Frames
Definition |
A table-like structure with columns of potentially different data types. |
Creating Data Frames |
|
Accessing Elements |
|
Common Functions |
|
Example |
|
Syntax and Basic Operations
Operators
Arithmetic |
|
Relational |
|
Logical |
|
Assignment |
|
Example |
|
Control Flow
if Statement |
|
if…else Statement |
|
for Loop |
|
while Loop |
|
Example |
|
Functions
Definition |
Reusable blocks of code that perform a specific task. |
Defining a Function |
|
Calling a Function |
|
Example |
|
Data Manipulation
dplyr Package
Description |
A powerful package for data manipulation. |
Key Functions |
|
Example |
|
tidyr Package
Description |
A package for tidying data. |
Key Functions |
|
Example |
|
Data Subsetting
Using Indices |
|
Using Logical Vectors |
|
Using |
|
Example |
|
Statistical Analysis
Descriptive Statistics
Functions |
|
Example |
|
Hypothesis Testing
t-tests |
|
Chi-squared Test |
|
Example |
|
Linear Regression
Function |
|
Example |
|