Skip to content
Permalink
Browse files
…-StudySafe into darl-chenc29
  • Loading branch information
chenc29 committed Sep 16, 2021
2 parents f0611ce + 4dda423 commit c9bc90a392cf886b513fedeccdb3f3f4dc7dcf0f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
33 app.R
@@ -1,4 +1,4 @@
# Data Incite RPI Study Safe App using UI Template
## Data Incite RPI Study Safe App using UI Template
# Uses Shinydashboard as a framework https://rstudio.github.io/shinydashboard/
# UI Template Created by Arielle Cerini, Brian Hotopp, Haoyu He, and James Young
# Edited by Kara Kniss
@@ -11,6 +11,9 @@ Sys.setenv(TZ="America/New_York")
#document for reading in the relevant libraries, data, and cleaning
source('read_wapData.R')

# Data for Roma's additions
buildinghoursAccessInfo <- read_csv("buildinghoursAccessInfo.csv")

# Suppress those dplyr warnings

#LINK TO FEEDBACK SURVEY
@@ -166,8 +169,9 @@ ui <- dashboardPage(skin = "black", title = "RPI StudySafe",
label= tags$div(HTML("<b><span style = 'color: #54585a'>List by Activity</span></b>")),
value = FALSE, status = "default", fill = TRUE, bigger = TRUE),
uiOutput("busy_info", align = "center"),
uiOutput("BuildingInfo", align = "center"),
plotOutput("hourly_crowd", click = "pick_time", height="20vh"),
h1("StudySafe uses near-real-time, anonymous WiFi data from the last 7 days")),
h1("StudySafe uses near-real-time, anonymous WiFi data from the last 3 weeks")),

)
),
@@ -229,7 +233,8 @@ server <- function(input, output, session) {
# get the buliding clicked from the lat and long of the marker
clicked_lat = input$campusMap_marker_click$lat
clicked_lng = input$campusMap_marker_click$lng
data <- rpi_wap_last7 %>% filter(weekday == application_state$day & lng == clicked_lng & lat == clicked_lat)
data <- user_predictions %>% filter(weekday == application_state$day & lng == clicked_lng & lat == clicked_lat)
#browser()
building <- (data$Building)[1]
updatePickerInput(session, inputId="user_selected_building", selected=building)
leafletProxy("campusMap") %>% clearGroup(group="selected") %>% addAwesomeMarkers(icon= icon, lat=clicked_lat, lng=clicked_lng, group="selected")
@@ -245,7 +250,7 @@ server <- function(input, output, session) {

# main leaflet map
output$campusMap <- renderLeaflet({
data <- rpi_wap_last7 %>% filter(weekday == application_state$day)
data <- user_predictions %>% filter(weekday == application_state$day)
point <- data %>% filter(Building == application_state$building) %>% select(lat,lng) %>% unique()
map_info <- get_map_info(data, application_state$time, hits_per_wap_semester_by_building_max)
leaf_map <- get_map(map_info, point$lat, point$lng)
@@ -255,18 +260,32 @@ server <- function(input, output, session) {
# "google-maps" style plot
output$hourly_crowd <- renderPlot({
# get data to feed into make_plot
data <- rpi_wap_last7 %>% filter(weekday == application_state$day & Building == application_state$building)
data <- user_predictions %>% filter(weekday == application_state$day & Building == application_state$building)
make_plot(data, application_state$time, application_state$building, hits_per_wap_semester_by_building_max)
}, bg="transparent")

# print information on how busy the building is
output$busy_info <- renderUI({
data <- rpi_wap_last7 %>% filter(weekday == application_state$day & Hour == application_state$time & Building == application_state$building)
data <- user_predictions %>% filter(weekday == application_state$day & Hour == application_state$time & Building == application_state$building)
text <- busy_text(data, application_state$building, hits_per_wap_semester_by_building_max)
time_ampm <- time.data[application_state$time+1,2]
p("At", time_ampm, " ", application_state$building,"is", text)
})

output$BuildingInfo <- renderUI({
if(application_state$building %in% buildinghoursAccessInfo$Building ){
#paste("You have selected" , building_select)
{stringr::str_c(application_state$building, "hours: ",buildinghoursAccessInfo[buildinghoursAccessInfo$Building == application_state$building, ]$TimeZone,
', Access:',
buildinghoursAccessInfo[buildinghoursAccessInfo$Building == application_state$building, ]$Mode, sep = " ")}
}
else{
paste("Building hours and access information for", application_state$building, "are not available at this time")
}
#paste("You have selected" , building_select)
})


# print title block
output$MT_title_summary <- renderText({
time_ampm <- time.data[application_state$time+1,2]
@@ -299,4 +318,4 @@ server <- function(input, output, session) {
}

# Run the application
shinyApp(ui = ui, server = server)
shinyApp(ui = ui, server = server)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c9bc90a

Please sign in to comment.