More R Flashcards
What is the workspace
the collection of objects you currently have/create during the r session. it is not stored in memory unless you tell r to do so.
install packages vs load package
install.package() vs library()
how to read matrix
read.matrix()
how to make the first row of csv be values
read.csv(… header = False)
how to export a text file
write.table(mydata, name of the file, sep = “\t”)
is.na()
returns true if there is a missing value/NAN, but returns false if there is a value
how to recode a missing value
mydata[mydata$v1==99,”v1”]
how to exclude a missing value from analysis
mean(x, na.rm = TRUE)
must the true of false be caps
YES
how to list rows that have missing values
mydata[!complete.cases(mydata),] this will print the rows which
what does the complete cases function give
indicates which rows are complete, have no missing data, in the form of a logical vector. if there are 3 rows with all complete values (TRUE, TRUE, TRUE)
how do you select certain rows in a matrix
mymatrix[c(2,4),], or mymatrix[c(2:4),] if you exclude the comma, it only gives the first column
how to find dimensions/shape of a matrix/dataframe
use dim(x)
what does na.omit do
it returns a new matrix/dataframe without the missing data
typeof/mode vs class
type gives the variable inside the container, while class gives the container structure