Sameer Mathur
Reading, Processing and Describing ISLR Data
Using data.table()
---
library(ISLR)
library(data.table)
# reading inbuilt data as data table
default.dt <- data.table(Default)
# reading inbuilt data as data frame
default.df <- as.data.frame(default.dt)
# boxplot of income by defaulters
boxplot(income ~ default, data = default.dt,
main = "Boxplot of Income by Defaulters",
xlab = "Defaulters", ylab = "Income (USD)",
col = c("grey", "light blue"))
# boxplot of income by defaulters
boxplot(income ~ default * student, data = default.dt,
main = "Boxplot of Income by Defaulters",
xlab = "Defaulters | Student", ylab = "Income (USD)",
col = c("grey", "light blue"))
library(lattice)# boxplot of income by defaulters
bwplot(income ~ default | student, data = default.dt,
horizontal = FALSE, xlab = "Defaulters")
# mean plot of income by defaulters
library(gplots)
plotmeans(income ~ default, data = default.dt,
xlab = "Defaulters", ylab = "Income (USD)",
frame = TRUE, mean.labels = TRUE)
# mean plot of balance by defaulters
library(gplots)
plotmeans(balance ~ default, data = default.dt,
xlab = "Defaulters", ylab = "Balance (USD)",
frame = TRUE, mean.labels = TRUE)
# scatter plot of income and balance by defaulters
xyplot(balance ~ income, group = default, data = default.dt,
ylab = "Balance (USD)", xlab = "Income (USD)",
main = "Scatter Plot of Income and Balance by Defaulters")
# scatter plot of income and balance by defaulters
xyplot(balance ~ income | default, data = default.dt,
ylab = "Balance (USD)", xlab = "Income (USD)",
main = "Scatter Plot of Income and Balance by Defaulters",
type = c("p", "smooth"), scales = "free")