4 Connecting R and Tableau

R and Tableau

image

image

image

image

image

image

image

imageimageimage

image

image

image

image

Case Study 2:

Visualize the frequency of bad credit rate obtained by different age group using histograms for a given “Loan dataset” in R.

#Visualize the frequency of bad credit rate obtained by different age group using histograms for a given “Loan dataset” in R.

df<-read.csv(“LoanData.csv”)

df

image

library(ggplot2)

ggplot(data=df, aes(x=Age.Group, y=Bad.Rate)) +geom_bar(stat=”identity”) + labs(x = “Age Group”, y = “Bad Credit Rate”)

image

ggplot(df, aes(x=Age.Group))+ geom_bar(aes(y=Number.of.Loans),stat=”identity”)+ geom_line(aes(y=(Bad.Rate-1)*2500, group = 1),stat=”identity”,color=”orange”)+

labs(x=”Age Groups”,y=”Number of Loans”)

image

ggplot(df, aes(x=Age.Group))+

geom_bar(aes(y=Number.of.Loans),stat=”identity”)+

geom_line(aes(y=(Bad.Rate-1)*2500, group = 1),stat=”identity”, color=”orange”)+

labs(x=”Age Groups”,y=”Number of Loans”)+

scale_y_continuous(sec.axis=sec_axis(~.*0.0004+1,name=”Bad Rate”))

image

ggplot(df, aes(x=Age.Group))+

geom_bar(aes(y=Number.of.Loans),stat=”identity”)+

geom_line(aes(y=(Bad.Rate-1)*2500, group = 1, color = “Bad Rate”),stat=”identity”,

show.legend=TRUE)+labs(x=”Age Groups”,y=”Number of Loans”)+

scale_color_manual(name = “Legend”, values = c(“Bad Rate” = “orange”))+

scale_y_continuous(sec.axis=sec_axis(~.*0.0004+1,name=”Bad Rate”))

image

Show the different inference (with 5 different sheets) of Loan dataset using Tableau. Apply the Tableau with R integration to identify the bad loan and good loan.

Integrating R with Tableau

image

image

image

image

image

image

image

image

image

image

image

image

image

 

Case Study 3:

Create Time series data visualizations using suitable statistical model and explore

the “Chicago_batteries” dataset using R. Create forecasting and Trend line charts that

highlight something interesting inference in “Chicago_batteries dataset” using Tableau.

Rstudio CODE:

#Create Time series data visualizations using suitable statistical model and explore the “Chicago_batteries” dataset using R. Create forecasting and Trend line charts that highlight something interesting inference in “Chicago_batteries dataset” using Tableau.

data <- read.csv(“C:/Users/admin/Downloads/chicago_batteries_2002_to_2013.csv”)

library(tseries) library(forecast) library(TTR) library(dplyr) library(lattice)

xyplot(data$ozone~data$daylight_hours|factor(data$month), data, xlab=”daylight_hours, ylab=”ozone, group=”day”)

datats<-ts(data)

plot.ts(datats, main=”plot of timeseries data”, col=”blue”) na.omit(datats)

datalogts<-log(datats)

plot.ts(datalogts, main=”plot of log of timeseries data”, col=”blue”)

summary(data) str(data) library(TTR) library(dplyr) cycle

xyplot(cycle~data$month) acf(datats) pacf((datats))

train<-data[1:2500,] test<-data[2501:4379,]

fit<-arima(datats, order = c(0L, 0L, 0L), seasonal = list(order = c(0L, 0L, 0L), period = NA), xreg = NULL, include.mean = TRUE, transform.pars = TRUE, fixed = NULL, init = NULL)

pred<-predict(fit,train) plot(pred)

plot(train)

Exploring the data:

image

image

image

datats<-ts(data)

plot.ts(datats, main=”plot of timeseries data”, col=”blue”)

image

pred<-predict(fit,train) plot(pred)

image

image image

#Plotting values of dataset

acf(datats)

image

License

Icon for the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

Data Visualization Insights - Hands-on Book Copyright © 2023 by Saint Peter's University is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book