Description Usage Format Details Examples
Data "MathPlacement" taken from Stat2Data package.
1 |
A data frame containing:
Identification number for each student
0=Female, 1=Male
PSAT score in Math
SAT score in Math
ACT Score in Math
Adjusted rank in HS class
Number of students in HS class
Adjusted GPA
Score on math placement exam
Recommended course: R0 R01 R1 R12 R2 R3 R4 R6 R8
Actual course taken
Course grade
1=recommended course, 0=otherwise
1=took course above recommended, 0=otherwise
1=took course below recommended, 0=otherwise
1=B or better grade, 0=grade below B
according to recommendations, which level of course was taken: alow - lower, bnormal - recommended, chigh - higher
Code for data modifications can be found in the example section.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | data(dataM)
library(magrittr)
library(dplyr)
if (requireNamespace("recipes", quietly = TRUE)&requireNamespace("Stat2Data", quietly = TRUE)) {
data("MathPlacement", package="Stat2Data")
head(MathPlacement)
library(recipes)
# As some of the data is missing, k-nearest neighbors (knn) imputation is
# used to fill the gaps. This is done with recipes package and function
# step_knnimpute.
dataM <- recipe(~ ., data = MathPlacement) %>%
step_knnimpute(everything()) %>% prep() %>% juice()
# Afterwards we create a categorical variable that will show whether a
# student took a course which was too high, too low, the recommended one or
# something else happened:
dataM %<>% mutate(Student = 1:n(), DR_Course = case_when(
TooHigh == 1 ~ "chigh",
TooLow == 1 ~ "alow",
RecTaken == 1 ~ "bnormal",
TRUE ~"dother"
))
# We remove observations with ambiguous course status:
dataM %<>% filter(DR_Course!="dother")
dataM %>% select(DR_Course) %>% table %>% t
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.