2023-04-15

Introduction

This is an R Markdown presentation using plotly to visualize some data. This presentation is created to satisfy the requirements of the week 3 of developing data products course.

Load and prep the data

library(plotly)
data <- swiss[, c("Fertility", "Agriculture", "Education", "Catholic", "Infant.Mortality")]
summary(data)
   Fertility      Agriculture      Education        Catholic      
 Min.   :35.00   Min.   : 1.20   Min.   : 1.00   Min.   :  2.150  
 1st Qu.:64.70   1st Qu.:35.90   1st Qu.: 6.00   1st Qu.:  5.195  
 Median :70.40   Median :54.10   Median : 8.00   Median : 15.140  
 Mean   :70.14   Mean   :50.66   Mean   :10.98   Mean   : 41.144  
 3rd Qu.:78.45   3rd Qu.:67.65   3rd Qu.:12.00   3rd Qu.: 93.125  
 Max.   :92.50   Max.   :89.70   Max.   :53.00   Max.   :100.000  
 Infant.Mortality
 Min.   :10.80   
 1st Qu.:18.15   
 Median :20.00   
 Mean   :19.94   
 3rd Qu.:21.70   
 Max.   :26.60   

Create 2D and 3D Scatter Plots

p1 <- plot_ly(data, x = ~Education, y = ~Fertility, color = ~Infant.Mortality,
        size = ~Fertility, text = ~paste("Agriculture: ", Agriculture))

p2 <- plot_ly(data, x = ~Catholic, y = ~Fertility, color = ~Infant.Mortality,
        size = ~Fertility, text = ~paste("Agriculture: ", Agriculture))

p3 <- plot_ly(data, x = ~Education, y = ~Fertility, z = ~Agriculture,
        color = ~Infant.Mortality, size = ~Fertility, 
        text = ~paste("Agriculture: ", Agriculture)) 

Fertility vs Education

This plot shows the Fertility vs. Education and it can been seen that there is some sort of relationship between lower infant mortality and education.

Fertility vs Catholic Faith

This plot shows the Fertility vs. Catholic faith. One cannot ascertain any form of correlation between lower infant mortality and faith from this graph.

3D Scatter Plot - Fertility, Education and Occupation

This is a 3D plot of Fertility, Education and Occupation. It can be seen that infant mortality is more of less uniformly spread across the Agriculture occupation.