Filter Course Schedule by College, Department, Program, Subject, and/or Instructor
Source:R/filter_schedule.R
filter_schedule.Rd
Applies one or more filters to a course schedule using pattern matching on instructor, subject, college, department, and program. All matching is case-insensitive and based on partial string matching.
Usage
filter_schedule(
schedule,
subject_pattern = NULL,
instructor_pattern = NULL,
college_pattern = NULL,
department_pattern = NULL,
program_pattern = NULL
)
Arguments
- schedule
A data frame containing the course schedule with required columns:
INSTRUCTOR
,SUBJ
. Optional columns include:COLLEGE
,DEPARTMENT
,PROGRAM
.- subject_pattern
Optional regex pattern to match subject codes (e.g., "CSCI", "^MATH").
- instructor_pattern
Optional regex pattern to match instructor names (e.g., "Smith", "^Jones").
- college_pattern
Optional regex pattern to match college names (e.g., "Science", "Engineering").
- department_pattern
Optional regex pattern to match department names (e.g., "Math", "Biology").
- program_pattern
Optional regex pattern to match program names (e.g., "Undergraduate", "MBA").
Examples
schedule <- data.frame(
INSTRUCTOR = c("Lee", "Smith", "Jones", "Dawson", "Garcia"),
SUBJ = c("MATH", "NURS", "CSCI", "ENGL", "COMM"),
COLLEGE = c("Science", "Nursing", "Science", "Arts and Sciences", "Arts and Communication"),
DEPARTMENT = c("Math", "Nursing", "CS", "English", "Comm Studies"),
PROGRAM = c("BS", "BSN", "BS", "BA", "BA"),
stringsAsFactors = FALSE
)
filter_schedule(schedule, subject_pattern = "^MATH|^STAT")
#> INSTRUCTOR SUBJ COLLEGE DEPARTMENT PROGRAM
#> 1 Lee MATH Science Math BS
filter_schedule(schedule, instructor_pattern = "smith")
#> INSTRUCTOR SUBJ COLLEGE DEPARTMENT PROGRAM
#> 1 Smith NURS Nursing Nursing BSN
filter_schedule(schedule, college_pattern = "Science")
#> INSTRUCTOR SUBJ COLLEGE DEPARTMENT PROGRAM
#> 1 Lee MATH Science Math BS
#> 2 Jones CSCI Science CS BS
#> 3 Dawson ENGL Arts and Sciences English BA
filter_schedule(schedule, department_pattern = "Comm")
#> INSTRUCTOR SUBJ COLLEGE DEPARTMENT PROGRAM
#> 1 Garcia COMM Arts and Communication Comm Studies BA
filter_schedule(schedule, program_pattern = "^BA$")
#> INSTRUCTOR SUBJ COLLEGE DEPARTMENT PROGRAM
#> 1 Dawson ENGL Arts and Sciences English BA
#> 2 Garcia COMM Arts and Communication Comm Studies BA