Rstudio 1 Flashcards
how to code an object called bob and make it represent 5
bob=5
how to code an object called bob and make it represent hello
bob=”hello”
what is an alternative to =
<-
how to calculate an equation with objects
bob + bob = 10
vector and how to make one called vector1
store of numbers/names in order, 1D, vector1= c(1, 2, 3, 4, 5) or vector1= c(1:5)
how to multiply a vectors values to change vector
vector1 * 5
to get mean/median/min/max of vector1
mean(vector1) etc
to get mean/median/min/max of a category in vector1
mean(vector1$category) etc
standard deviation
how much the data spreads from the average, sd(vector1)
sample size
counts the amount of data, in a vector, length(vector1)
dataframe
2D, several vectors form a dataframe
to repeat a vector two times (for example)
name the repeating command, rep1 = rep(vector1, 2) so there will be 10 samples not 5
how to get random numbers
make new vector, vector2 = rnorm(10, mean = 5, sd = 2), 10 sample size
merge vectors together
change first vector to data frame, first name dataframe (mydata), mydata= as.data.frame(vector1, stringsAsFactors = T), then add another vector by mydata$category1 = vector1
to get overview of dataframe/vector
summary(mydata$category1) or str(mydata$category1)