KEVIN CLOYD DIVINAGRACIA
BSCS 3B
CASESTUDY
Discussion of Method
Here is how the code addresses each specific problem identified in your image:
1. P1 (Whitespace and Type):
o Method: I used str_squish() (from the stringr package) to trim
leading/trailing whitespace and [Link]() to convert the text to
numbers.
o Why: The original column was read as character data (text) because of
the spaces. This function forces it into a number format so we can
perform calculations later.
2. P2 & P3 (Text & Categorical Inconsistency):
o Method: I applied str_to_title() to both the "Reported By" and "Priority"
columns.
o Why: This standardizes messy inputs like "BOB", "medium", or "HIGH"
into a consistent "Title Case" format ("Bob", "Medium", "High"),
ensuring categories group together correctly in analysis.
3. P4 (Outlier & Missing Data):
o Method:
Capping: I used an ifelse statement. If the time was greater
than 180, it was replaced with 180; otherwise, it stayed the
same.
Imputation: I used replace_na() combined with median().
o Logic: It is crucial to cap the outlier before calculating the median. If
we included the "impossible" 1000-minute value in the median
calculation, it would skew the result.
4. P5 (Date Formatting):
o Method: I used parse_date_time() from the lubridate package with the
argument orders = c("ymd", "mdy").
o Why: The data contained two formats: 2025-03-01 (Year-Month-Day)
and 03/02/2025 (Month/Day/Year). parse_date_time is smart enough to
detect which format a specific row is using and convert them all to a
single standard Date object.