IT408 / IT408 SC:
Data Mining

Unit 4: Data Visualization

R Batzinger

2026-06-08

Tidy models

Course Textbook:

Hadley Wickham,Mine Cetinkaya-Rundel and Garrett Grolemund, R for data science: import, tidy, transform, visualize, and model data. 2nd Edition, O’Reilly Press

Online version: https://r4ds.hadley.nz/ ## Schedule {.scrollable}

  • June
Su Mn Tu We Th Fr Sa
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] 26 27
28 [29] 30
  • July
Su Mn Tu We Th Fr Sa
(1)* [[2]] 3 4
5 [6] 7 (8)* [9] 10 11
12 [13] 14 (15)* [16]L 17 18
21 [20] 21 22 [23] [[24]] 25
26 27 28 29 30 31
* IT408 Special Studies; L - Lab test

R Notebook

  • Title
  • Authors
  • Date
  • Abstract
  • Introduction
    • The nature of the problem
    • What work has been done before
    • Key Research Objectives
  • Methodology
  • Results
  • Discussion
  • Conclusion
    • Possible steps for future research
  • Bibliography

Scatterplot

plot(mtcars$wt, mtcars$mpg)

library(tidyverse)
library(gdata)
library(gcookbook)
qplot(wt, mpg, data=mtcars)

ggplot(mtcars, aes(x=wt, y=mpg,color=cyl)) + geom_point()

Line Graph

time = 1:200 
A= 20
p = 2
b =0.05

DrugA = A*time^p*exp(-b*time)
DrugB = A*time^p*exp(-sqrt(2)*b*time)
DrugC = 2*A*time^p*exp(-2*b*time)

  plot(time, DrugA, type="l",col="blue",lwd=2,
       main="Blood Concentration after Injection",
       xlab="Time (in minutes)",
       ylab="Units (per ml blood)")
  points(time,DrugA,col="blue")
  lines(time,DrugB, col="red", lwd=2)
  points(time,DrugB, col="red")
   lines(time,DrugC, col="orange", lwd=2)
   points(time,DrugC,col="orange")
   
   legend(140,4000,c("DrugA","DrugB","DrugC"),fill=c("blue","red","orange"))

drugdta = data.frame(time,DrugA,DrugB,DrugC)
drugdta |> ggplot(aes(x=time,y=DrugA)) + geom_line(aes(x=time,y=DrugA,col="DrugA")) + geom_point(aes(x=time,y=DrugA,color="DrugA")) + geom_line(aes(x=time,y=DrugB,color="DrugB")) + geom_point(aes(x=time,y=DrugB,color="DrugB")) +
  geom_line(aes(x=time,y=DrugC,color="DrugC")) + geom_point(aes(x=time,y=DrugC,color="DrugC")) + theme(legend.position=c(.9,.9),legend.justification=c(1,1),)+labs(x="Time (in seconds)", y="Drug Concentration",
          title="Comparison of Blood Concentrations after Injection")

Data Cleansing Exercise

df <- data.frame(
  Employee_ID = c(101, 102, 103, 104, 105, 106, 107, 103, 108, 109),
  Age = c(28, 34, 41, NA, 32, 29, 145, 41, 36, 31),
  Salary_USD = c(55000, 62000, 78000, 51000, 2, 58000,
      85000, 78000, 69000, 950000)
)