1 Flashcards
x %% y = ?
Modulo (remainder)
x %/% y = ?
Integer Addition (quotient)
How to make an R vector?
c(x,y,z)
How to create an R vector by using a range?
x:y
E.g., var <- x:y
How to create a vector using a range at specified increments?
seq(from=x, to= y, by=z)
How to create an R vector with a certain number of increments yet hitting the max value?
seq(from = x, to = y, length = z)
How to replicate a vector in R?
rep(vector, times = x)
How to merge vectors in R?
Create vectors as vars, and then assign them to a new vector as c().
How to turn vectors into arrays?
var = 1:4
var[]
How to remove indexes from arrays in R?
array[-x]
How to record how many elements are in a vector in R?
length(vector)
How to extract unique (eliminating repeated elements) elements in a vector in R?
E.g., (1,2,2,3,2,3,4) -> (1,2,3,4)
unique(vector)
How to determine how many times an element appears in a vector in R?
table(vector)
How to extract the title names of a table in R?
names(table(vector))
How to extract the values from a table in R?
table(vector)[index]