Cheatography
https://cheatography.com
Basic R commands used in lecture.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
R as a Calculator
|
Exponential |
|
Sum. |
|
Natural log. |
|
Cumulative Sum. |
|
Largest element. |
|
Round up. |
|
Smallest element. |
|
Round down. |
|
Mean. |
|
Median. |
|
Variance. |
|
Percentage quantiles. |
|
Modulo |
Univariate Data: I/O
write(data, "mydata.dat")
|
Write data as binary. |
|
Read binary data. |
Univariate Data: Plotting
|
Plot quick overview. |
|
Barplot of absolute frequencies. |
|
Plot ECDF. |
|
Histogram of relative frequencies. |
|
1D-plot |
|
Specify subdivisions of histogram. |
Creating Vectors
|
Join elements into a vector |
|
An integer sequence (end inclusive!) |
|
Complex sequence (s. np.linspace) |
|
Repeat vector |
|
Repeat each element |
Vecotr Functions
|
Return x sorted. |
|
Return x reversed. |
|
See counts of values. |
|
See unique values. |
|
Length of x. |
Selecting Vector Elements
By Position |
|
The fourth element |
|
All but the fourth. |
|
Elements two to four |
|
All elements except 2 to four |
|
Elements one and five. |
By Value |
|
All elements equal to 10 |
|
All elements less than 10. |
|
Elements in the given set. |
Named Vectors |
|
Element with name 'apple'. |
Runs Test of Randomness
|
Compute the lengths and values of runs of equal values in a vector . |
|
Vector containing the length of each run. |
|
Vector of the same length as lengths with the corresponding values. |
|