12/2/2021

Info dataset

Swiss Fertility and Socioeconomic Indicators (1888)

Standardized fertility measure and socio-economic indicators for each of 47 French-speaking provinces of Switzerland at about 1888.

library(plotly)
head(swiss)
             Fertility Agriculture Examination Education Catholic
Courtelary        80.2        17.0          15        12     9.96
Delemont          83.1        45.1           6         9    84.84
Franches-Mnt      92.5        39.7           5         5    93.40
Moutier           85.8        36.5          12         7    33.77
Neuveville        76.9        43.5          17        15     5.16
Porrentruy        76.1        35.3           9         7    90.57
             Infant.Mortality
Courtelary               22.2
Delemont                 22.2
Franches-Mnt             20.2
Moutier                  20.3
Neuveville               20.6
Porrentruy               26.6

Summary dataset

summary(swiss)
   Fertility      Agriculture     Examination      Education    
 Min.   :35.00   Min.   : 1.20   Min.   : 3.00   Min.   : 1.00  
 1st Qu.:64.70   1st Qu.:35.90   1st Qu.:12.00   1st Qu.: 6.00  
 Median :70.40   Median :54.10   Median :16.00   Median : 8.00  
 Mean   :70.14   Mean   :50.66   Mean   :16.49   Mean   :10.98  
 3rd Qu.:78.45   3rd Qu.:67.65   3rd Qu.:22.00   3rd Qu.:12.00  
 Max.   :92.50   Max.   :89.70   Max.   :37.00   Max.   :53.00  
    Catholic       Infant.Mortality
 Min.   :  2.150   Min.   :10.80   
 1st Qu.:  5.195   1st Qu.:18.15   
 Median : 15.140   Median :20.00   
 Mean   : 41.144   Mean   :19.94   
 3rd Qu.: 93.125   3rd Qu.:21.70   
 Max.   :100.000   Max.   :26.60   

Plot with “plotly”

plot_ly(swiss, x = ~Fertility, y = ~Infant.Mortality , mode = "markers",
        type = "scatter", color = ~Education) %>% 
  layout(title="Swiss Fertility and Socieconomic Indicators 1888")

Plotly 3d

Now, a col factor was created

swiss$factor= cut(x = swiss$Education , breaks = 3, labels = c(
"Low Educational lvl", "Medium Educational lvl", "High Educational lvl"))
plot_ly(swiss, x = ~Fertility, y = ~Infant.Mortality, z = ~Agriculture ,
        mode = "markers", type = "scatter3d", color = ~factor)

plotly boxplot

plot_ly(swiss, x = ~factor, y = ~Infant.Mortality, color= ~factor, 
        type = "box")

headmap with plotly

plot_ly( z = volcano, type="surface")