Visualizing Data from existing Data in a csv or excel file or txt
Histogram of Income from Credit data
library(readr)
Credit <- read_csv("Credit.csv")
## Parsed with column specification:
## cols(
## id = col_double(),
## Income = col_double(),
## Limit = col_double(),
## Rating = col_double(),
## Cards = col_double(),
## Age = col_double(),
## Education = col_double(),
## Gender = col_character(),
## Student = col_character(),
## Married = col_character(),
## Ethnicity = col_character(),
## Balance = col_double()
## )
icm <- Credit$Income
hist(icm,
# breaks tell R how many bars you want
# R can decide to choose what is reasonable
breaks = 10,
main = "Income Distribution",
xlab = "Income",
xlim = c(0,250),
ylim = c(0,200),
col = "grey",
freq = TRUE)

Histogram of Balance from Credit Card Data
bal <- Credit$Balance
hist(bal,
# breaks tell R how many bars you want
# R can decide to choose what is reasonable
breaks = 12,
main = "Balance Distribution",
xlab = "Balance",
xlim = c(0,2500),
ylim = c(0,150),
col = "red",
freq = TRUE)

Bar Graph of Ethnicity from Credit Card Data
ethty <- Credit$Ethnicity
ethty_1 <- table(ethty)
barplot(ethty_1,
main = "Bar Graph of Ethnicity",
xlab = "Ethnicity",
ylab = "Frequency",
ylim = c(0,250),
col="green")

Pie Chart of Ethnicity from Credit Card Data
ethty <- Credit$Ethnicity
ethty_1 <- table(ethty)
# calculate percentages
pct <- round(ethty_1/sum(ethty_1)*100,2)
# add percents to labels
lbls <- paste(names(ethty_1), pct, "%")
pie(ethty_1,
main = "Pie Chart of Ethnicity",
col=c("grey", "skyblue3", "skyblue1"),
labels=lbls)
