Santiago Escuder
11/09/2021
El codigo Shiny de esta App se encuentra en https://github.com/SantiagoEscuder/Shiny-App-Coursera.
BASE_BM_Latinoamerica_TIC <- read.csv('BASE_BM_Latinoamerica_TIC.csv', header=TRUE, sep=';',dec=',',row.names=1)
head(BASE_BM_Latinoamerica_TIC)
Selvatica Electricidad Celulares Banda_Ancha
Argentina 10.1 99.8 158.7 14.6
Antigua y Barbuda 22.3 90.9 120.0 17.4
Bahamas 51.4 100.0 71.4 4.1
Belice 60.3 100.0 50.7 3.0
Brasil 59.3 99.5 139.0 10.7
Barbados 14.7 90.9 106.8 23.8
Usuarios_Internet Rural Urbana TIC_importacion
Argentina 64.7 8.4 91.6 8.5
Antigua y Barbuda 64.0 75.8 24.2 2.3
Bahamas 76.9 17.2 82.8 2.9
Belice 38.7 55.9 44.1 2.8
Brasil 57.6 14.6 85.4 8.6
Barbados 76.7 68.4 31.6 5.4
TIC_exportacion
Argentina 0.2
Antigua y Barbuda 4.9
Bahamas 0.3
Belice 0.3
Brasil 0.5
Barbados 0.7
summary(BASE_BM_Latinoamerica_TIC)
Selvatica Electricidad Celulares Banda_Ancha
Min. :10.10 Min. : 78.50 Min. : 50.7 Min. : 2.300
1st Qu.:22.48 1st Qu.: 91.55 1st Qu.:102.9 1st Qu.: 4.525
Median :45.70 Median : 97.70 Median :106.7 Median : 7.000
Mean :40.10 Mean : 94.87 Mean :112.9 Mean : 9.217
3rd Qu.:53.17 3rd Qu.: 99.58 3rd Qu.:137.6 3rd Qu.:12.500
Max. :84.10 Max. :100.00 Max. :160.8 Max. :23.800
Usuarios_Internet Rural Urbana TIC_importacion
Min. :23.40 Min. : 4.80 Min. :24.20 Min. : 2.300
1st Qu.:40.27 1st Qu.:15.25 1st Qu.:51.98 1st Qu.: 3.225
Median :51.00 Median :28.90 Median :71.10 Median : 5.900
Mean :51.59 Mean :34.06 Mean :65.94 Mean : 6.933
3rd Qu.:63.38 3rd Qu.:48.02 3rd Qu.:84.75 3rd Qu.: 8.325
Max. :76.90 Max. :75.80 Max. :95.20 Max. :18.500
TIC_exportacion
Min. : 0.000
1st Qu.: 0.100
Median : 0.300
Mean : 1.711
3rd Qu.: 0.400
Max. :21.900
Selvatica Electricidad Celulares Banda_Ancha
Selvatica 1.00000000 -0.1444700 -0.6414661 -0.58307746
Electricidad -0.14446997 1.0000000 0.2712386 0.18465234
Celulares -0.64146605 0.2712386 1.0000000 0.54440230
Banda_Ancha -0.58307746 0.1846523 0.5444023 1.00000000
Usuarios_Internet -0.30869812 0.4962330 0.2054650 0.69677799
Rural 0.12270907 -0.6526159 -0.5036879 -0.04559196
Urbana -0.12270907 0.6526159 0.5036879 0.04559196
TIC_importacion 0.03326816 0.3273724 0.4063304 -0.03410334
TIC_exportacion 0.09166027 0.1370087 0.2690080 0.10902250
Usuarios_Internet Rural Urbana
Selvatica -0.30869812 0.122709072 -0.122709072
Electricidad 0.49623299 -0.652615866 0.652615866
Celulares 0.20546498 -0.503687923 0.503687923
Banda_Ancha 0.69677799 -0.045591959 0.045591959
Usuarios_Internet 1.00000000 -0.274202512 0.274202512
Rural -0.27420251 1.000000000 -1.000000000
Urbana 0.27420251 -1.000000000 1.000000000
TIC_importacion -0.04595998 -0.323118305 0.323118305
TIC_exportacion 0.01819244 -0.003351326 0.003351326
TIC_importacion TIC_exportacion
Selvatica 0.03326816 0.091660274
Electricidad 0.32737243 0.137008708
Celulares 0.40633041 0.269007952
Banda_Ancha -0.03410334 0.109022497
Usuarios_Internet -0.04595998 0.018192439
Rural -0.32311830 -0.003351326
Urbana 0.32311830 0.003351326
TIC_importacion 1.00000000 0.548175835
TIC_exportacion 0.54817583 1.000000000
vars <- setdiff(names(BASE_BM_Latinoamerica_TIC), “Pais”)
pageWithSidebar( headerPanel('Clustering de paises de acuerdo a indicadores TIC'), sidebarPanel( selectInput('xcol', 'X Variable', vars), selectInput('ycol', 'Y Variable', vars, selected = vars[[2]]), numericInput('clusters', 'Numero clusters', 3, min = 1, max = 9) ), mainPanel( plotOutput('plot1'), h4(“Se trata de un analisis de una base de paises latinoamericanos segun diferentes indicadores TIC. Todas las variables se encuetran medidas en porcentaje Por mas informacion ver: https://datos.bancomundial.org/indicador”)) )
function(input, output, session) {
# Combine the selected variables into a new data frame selectedData <- reactive({ BASE_BM_Latinoamerica_TIC[, c(input$xcol, input$ycol)] })
clusters <- reactive({ kmeans(selectedData(), input$clusters) })
output$plot1 <- renderPlot({ palette(c(“#E41A1C”, “#377EB8”, “#4DAF4A”, “#984EA3”, “#FF7F00”, “#FFFF33”, “#A65628”, “#F781BF”, “#999999”)) par(mar = c(5.1, 4.1, 0, 1)) plot(selectedData(), col = clusters()$cluster, pch = 20, cex = 3) points(clusters()$centers, pch = 4, cex = 4, lwd = 4) text(selectedData(), row.names(BASE_BM_Latinoamerica_TIC), cex=0.9, pos=4, col=“black”) })
}