1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What does the subset()
function do in R?
It creates a subset of a dataframe based on specified conditions.
What’s the difference between &
and |
in R?
&
is used for intersections (both conditions must be true), |
is used for unions (at least one condition must be true).
How do you find the intersection of high suspension and high enrollment schools?
subset(schools, Total_suspensions > 75 & Enrollment > 611)
What is conditional probability in R?
It’s the probability of an event occurring given a specific condition or subset.
How do you calculate the conditional probability of attendance > 95 in a subset?
unionattenroll$highatt <- unionattenroll$Attendance > 95
mean(unionattenroll$highatt)
How do you compare conditional and unconditional probabilities?
Use mean()
on both the subset and full dataset for the same condition.
How do you create a binary indicator for (variable) gifted education > 3?
schools$highgifted <- NA
schools$highgifted[schools$Gifted_education > 3] <- 1
schools$highgifted[schools$Gifted_education <= 3] <- 0
How do you find average enrollment by school level?
aggregate(Enrollment ~ SCHOOL_LEVEL_NAME, data = schools, FUN = mean)
How do you analyze drug infractions across school types?
schools$drugbinary <- ifelse(schools$Drugs > 0, 1, 0)
aggregate(drugbinary ~ SCHOOL_LEVEL_NAME, data = schools, FUN = mean)