5 Flashcards
List in R?
A vector like thing where the elements can be anything in the same list.
list()
Sublist in R?
x[c(x, b)]
Extracting value from a list?
x$name_of_element or x[[1]] where first square brackets get the name of element place and the second extract the value of it.
Dataframe in R?
data.frame(vector1, vector2, vector3, vector4, vector5, stringsAsFactors = FALSE), since we don’t want our strings to be turned into factors, where the vectors get turned into columns.
What do the rows of a data frame mean?
The characteristics
Combine the rows/characteristics of two the same data frames to one?
rbind(dataframe1, dataframe2)
How to add a new vectors/columns to a dataframe?
cbind(dataframe, vector)
Extract column from dataframe?
dataframe$column_name, dataframe[rows,columns]
Scatterplot?
plot(x, y, xlab = “x label”, ylab = “y label”, main = “title”)
qqplot?
qqplot(x, y)
Mosaic plot?
mosaicplot(~y+z, data = dataframe, xlab, ylab, main, col=c())
Boxplot?
boxplot(dataframe$column, horizontal = TRUE/FALSE, )
Comparing box plots?
boxplot(numerical_vector/column1~categorical_vector/column2, data = dataframe)
Barplot?
barplot(table(vector)) so it can give you the counts/frequencies of each categorical variable.
Which must be equal lengths of the two vectors: scatter plot or qqplot?
Scatter plot