R Cheatsheet
Sources:
- **
Package Management
- Installation:
- Installed Package Metadata:
- Print list of functions in package:
- Unload/Detach Library:
Store Variable Inside Package Environment:
Scripting
Use this first line for R scripts:
Ask for user input in Rscript:
Getting help
Get help about any R function or structure:
# documentation of the `rle` function
?rle
# documentation of the `read.csv` function
?read.csv
Objects in memory
# list objects in memory
ls()
# delete objects from memory
rm('variablename')
# delete all objects
rm(list = ls())
Navigating in the filesystem
# current working directory
getwd()
# change to another directory
setwd('/path/to/somewhere/else')
Extracting subsets from data frames
# these are the same
subset(airquality, Month == 5)
subset(airquality, airquality[,'Month'] == 5)
subset(airquality, airquality[,5] == 5)
Misc
Modulo operator:
# 5 mod 3 is 2
# 3 mod 5 is 3
i %% n
Appendix
Note created on 2024-03-28 and last modified on 2024-03-28.
Backlinks
(c) No Clocks, LLC | 2024