Data Analytics R Flashcards
(274 cards)
Add 5 and 49
5+49
Subtract 5 from 49
49-5
Display a sequence of integers from 1 to 20
1:20
Multiply 3 by 5
3*5
Divide 12 by 4
12 / 4
Two to the power of three
2^3
Square root of 2
sqrt(2)
Sine of pi
sin(pi)
Exponential of 1
exp(1)
Log 10 to the base of e
log(10)
Log 10 to the base of 10
log(10, base = 10)
Add a comment in R
#
Add a mass comment in R
Control, shift, C
Remove a variable
rm(var) or remove(var)
How do you investigate a dataset or function in R?
?function
What is the first thing you should do when presented with a dataset?
Investigate the variables - use head(dataset) or ?dataset in the console.
How do you refer to variables created in the R markdown?
Backticks r var_name
How do you print to the markdown?
- Type the variable name that you want to print directly
- Paste()
- Paste0()
How do you assign to an object? What is the benefit of this?
Use <-
We can store it in the R workspace and save it for future use.
How do you calculate the mean?
mean(x)
How do you calculate the variance?
var(x)
Longhand: sum((x-mean(x))^2)/(n-1)
Find the size / the number of objects in a vector or list.
length(x)
Find the maximum, minimum and range of a vector of objects.
- max(x)
- min(x)
- range(x) - this will paste both
What function is used to collect things together into a vector?
x <- c(0, 7, 8)