Lesson 3 Flashcards
Creating a basic sequence of numbers e.g. 1-15
x < - 1:15
Sequence function
seq(x)
e.g. seq(from=x, to=y)
Creating a sequence with numbers incremented by a certain value
seq(x, y, by=z)
Creating a sequence of X numbers between Y and Z
seq(y, z, length=x)
Generating a sequence of numbers the length of an already created vector
1:length(vectorX)
seq(along.with = vectorX)
Replicate function
rep(x)
Getting rid of all values greater or equal to X in vectorY (indexing)
vectorY < - vectorY [vectorY < X]
Getting rid of certain values within a vector
vector < - vector [-c(x, y)]
Creating a list
list(x)
Getting the X element of the Y vector inside a list
list [[Y]] [X]
Naming vectors inside a list
names(list) < - c(“vector1”, “vector2”…)
Indexing a named vector
list $ vectorX [y]
Creating a data frame
data.frame(vectorX, vectorY, vectorZ…)
Printing elements inside a data frame
df [rowX, colY]