-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Pazionados.R
100 lines (88 loc) · 4.15 KB
/
A_Pazionados.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
library(shiny)
library(leaflet)
library(ggplot2)
library(ggmap)
library(data.table)
library(stringr)
ui <- bootstrapPage(
#map element
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%"),
# select category and country
absolutePanel( bottom = 30, left = 20, align = "center",
h1(style = "font-family:Averia Sans Libre; font-weight: 700; color: #e4d89a;","A Pazionados"),
h4(
style = "font-family:Averia Sans Libre; font-weight: 400; color: #abaebf;","a collaboration between"),
h3(
style = "margin-top: 10px; font-family:Averia Sans Libre; font-weight: 700; color: #abaebf;",
a(style = "color: #abaebf", href = "www.andreaarzaba.com","Andrea Arzaba"), "and",
a(style = "color: #abaebf", href = "www.collinschwantes.com", "Collin Schwantes")
)
),
absolutePanel(style = "background-color:rgba(0,0,8,.5); font-family:Averia Sans Libre; font-weight: 600;line-height: 2; color: #FFFFFF;",
width = "300px", top = 10, right = 10,
selectInput(selected = "All",inputId = "category",label = "Project Type",
choices = list("All" = "All",
"Art" = "Art",
"Community Engagement" = "Community Engagement",
"Education" = "Education",
"Media" = "Media",
"Sports" = "Sports")),
selectInput(selected = "All", "country", "Country",
choices = list("All" = "All",
"Ecuador" = "ecuador",
"El Salvador" = "el salvador",
"Guatemala" = "guatemala",
"Mexico" = "mexico",
"Venezuela" = "venezuela")),
h2(style = "font-family:Averia Sans Libre; font-weight: 700; color: #FFFFFF;", textOutput(outputId = "title")),
imageOutput(outputId = "image", height = "75%"),
h3(style = "font-family:Averia Sans Libre; font-weight: 400; color: #FFFFFF;", textOutput(outputId = "summary"))
)
)
server <- function(input, output) {
df <- read.csv(file = "./Apazionados.csv")
df <- cbind(df, geocode(as.character(df$City), output = "more"))
df$country <- as.factor(df$country)
df$lon <- as.factor(df$lon)
df$dest <- paste("./www/", df[,2], str_sub(df$Image, -4), sep = "")
for(i in df$Image){
download.file(url = as.character(i), destfile = df[df$Image == i, 25])
}
#INPUTS From categories
#default should be all
points <- reactive ({
if((input$category == "All") & (input$country == "All")) {df} else {
if((input$category == "All") & (input$country != "All")) {df_subco <- df[df$country == input$country,]} else {
if((input$category != "All") & (input$country == "All")) {df_subca <- df[df$Category == input$category,]} else {
df_sub <- df[df$Category == input$category,]
df_sub <- df_sub[df$country == input$country,]}
}
}
})
output$map <- renderLeaflet({
leaflet(df) %>%
setView(lng = -86.257367, lat = 0, zoom = 3) %>%
addProviderTiles("NASAGIBS.ViirsEarthAtNight2012")
})
#markers
observe({leafletProxy("map", data = points()) %>% clearMarkers() %>%
addMarkers(lng = ~lon, lat = ~lat)
})
output$title <- renderText({
click <- (input$map_marker_click)
long <- as.numeric(click[4])
obj <- as.character(df[df$lon == long,2])
})
output$image <- renderImage({
click <- (input$map_marker_click)
long <- as.numeric(click[4])
list(src = df[df$lon == long,25], width = 300)
}, deleteFile = FALSE)
output$summary <- renderText({
click <- (input$map_marker_click)
long <- as.numeric(click[4])
obj <- as.character(df[df$lon == long,4])
})
}
shinyApp(ui, server)