1/41
A review set of vocabulary flashcards covering basic R commands, functions, and operations from BAT 402.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
str(df)
Shows the structure of the dataset, including column types and sample values.
head(df)
Shows the first 6 rows.
dim(df)
Shows the number of rows and columns.
summary(df)
Gives a quick statistical summary of the dataset.
mean(df$column_name)
Finds the average.
median(df$column_name)
Finds the middle value.
sum(df$column_name)
Adds all values together.
max(df$column_name)
Finds the largest value.
min(df$column_name)
Finds the smallest value.
table(df$column_name)
Counts how often each value/category appears.
is.na(df$column_name)
Checks which values are missing (NA).
colSums(is.na(df))
Counts missing values in each column.
colMeans(is.na(df))
Finds the proportion of missing values in each column.
round(…, 1)
Rounds a result to 1 decimal place.
df$column_name[is.na(df$column_name)] <- "value"
Fills missing values with a chosen value/category.
median(df$column_name, na.rm=TRUE)
Finds the median while ignoring missing values.
mean(df$column_name, na.rm=TRUE)
Finds the mean while ignoring missing values.
duplicated(df)
Checks which rows are duplicates.
sum(duplicated(df))
Counts the duplicate rows.
df[duplicated(df), ]
Displays the duplicate rows.
summary(df$column_name)
Check the minimum and maximum for unusual values.
boxplot(df$column_name, main = "…", ylab = "…")
Creates a boxplot to visualize the distribution and possible outliers.
main = "…"
Sets the graph title.
ylab = "…"
Sets the Y-axis label.
df$column_name[df$column_name == 12000] <- 12
Replaces an incorrect value.
df
Keeps only rows where the column is greater than 0.
Assignment operator. Stores a value/result.
==
Checks if two values are equal.
>
Checks if one value is greater than another.
as.Date(df$column_name)
Converts a column to Date type.
as.factor(df$column_name)
Converts a categorical column to factor.
as.character(df$column_name)
Converts a value/column to text.
as.integer(df$column_name)
Converts a value/column to integer.
as.integer(TRUE/FALSE)
Converts TRUE/FALSE to 1/0.
df$column_name <- df$column_name / df$column_name
Creates a new ratio from two columns.
df$column_name <- as.integer(condition)
Creates a 1/0 yes/no flag.
c("value1", "value2")
Combines values into a vector/list.
head(df[, c("column_name", "column_name")])
Shows the first rows of selected columns.
format(df$column_name, "%m")
Extracts the month number from a Date.
as.integer(format(df$column_name, "%m"))
Gets the month as an integer.
weekdays(df$column_name)
Gets the day of the week.
df$column_name %in% c("Saturday", "Sunday")
Checks whether a value is Saturday or Sunday.