Common Functions Flashcards
getwd()
Get working directory
setwd(“x”)
x is path to working directory
Set working directory
install.packages(“x”)
x is package name
Installs package
library(x)
x is package name
Load a package
print(x)
x is a variable
Display contents of a variable
nrow(df)
df is a data frame
Determine the number of rows in a data frame or matrix
ncol(df)
df is a data frame
Determine the number of columns in a data frame or matrix
rm(x)
x is a variable
Delete a variable from your programming environment
read_csv(“data.csv”)
data.csv is a file
read a CSV (comma-separated value) file and create a data frame
write.csv(“output.csv”)
output.csv is a file
exports the data frame as a csv file
sd(df$Age)
Age is a column in the data frame
Calculate the standard deviation
help(package = “x”)
x is a package name
find help for a package
mean(df$Age)
Age is a column in a data frame
calculate the average
summary(df)
df is a data frame
provide a summary of descriptive stats for each variable in a data frame
head(df)
df is a data frame
View the first few rows of a data frame or matrix
tail(df)
df is a data frame
View the last few rows of a data frame or matrix
str(df)
df is a data frame
Display a structure of a data frame or matrix