Chapter 1 - Introduction to R Flashcards
Memorize common functions
Exponential/Log functions
exp(…) and log(x, base)
Install a package and load
install.packages(‘…’), library(package)
Scatter plot
plot(X,Y)
Histogram
hist(X)
Make a vector
x <- c(…)
Sum, Mean, Standard dev, length of a vector?
sum(), mean(), sd(), length()
Multiple plots at once? 1 row 2 col? 2 row 1 col?
par(mfrow = c(1,2)) and par(mfrow = c(2,1))
Make lines in a plot
lines(X,Y)
What order does R upcast to for vectors?
Boolean -> Numeric -> String
Check object types for numeric, factor, logical, and character.
as.”type”
Print a string without quotations.
cat(…)
Count the number of characters in a string.
nchar(a)
Character translation function
chartr(old, new, string)
Make a string upper case, lower case?
toupper(a), tolower(a)
Get a sub-string.
substr(beg,end,string)