More R Flashcards
What is R
a programming language used for data analytics, statistics
how is it similar to python
it is an interpreted language
object names rules
letters, names and underscores only
data structures in r
vector, list one dimension. matrix, dataframe, 2 dimension
how to index vectors
vector[2]. or vector[c(2,3)]
format of matrices
mymatrix = matrix(vector, nrow = x, ncol = y, byrow = False, dimnames = list(c(“row names”), c(“column names”)))
how to index matrices
y[,4] # 4th column of matrix
y[3,] # 3rd row of matrix
y[2:4,1:3] # rows 2,3,4 of columns 1,2,3
are lists ordered
yes
can lists contain elements of different types
yes
how to index lists
thisisalist[[2]]
do all columns in the matrix have to have the same mode (numeric, integer, factor, text)
Yes
can different columns in the data frame have different modes
yes
what is the code for dataframes
mydata = data.frame(vector1, vector2, vector3)
how to index dataframes
dataframe[1:3, 2:4]
mydata[c(“ID”, “Passed”)] (the column names)
mydata$X1 (the column X1)