Skip to content
Permalink
164c9b3b5c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
65 lines (51 sloc) 3.2 KB
#Reading in the data and necessary libraries for RPI StudySafe App
#Created by Kara Kniss
#Reading in the necessary libraries
library(shiny)
library(shinydashboard)
library(shinyjs)
library(ggplot2)
library(shinyWidgets)
library(tidyverse)
library(tidyr)
library(lubridate)
library(xlsx)
library(plyr)
library(scales)
library(zoo)
library(ggalt)
library(leaflet)
library(RColorBrewer)
library(viridis)
library(reactable)
###READING IN NECESSARY FILES
#reading in the WAP last seven days data
rpi_wap_raw <- readRDS("../../COVID_RPI_WiFi_Data/rpi_wap_raw.rds")
combined_wap_data <- readRDS("../../COVID_RPI_WiFi_Data/combined_wap_data.rds")
#Reading in WAP semester with devname summary statistics (usercount mean, median, max)
rpi_wap_stats <- readRDS("../../COVID_RPI_WiFi_Data/rpi_wifi_semester_day_summary.rds")
#Reading in semester WAP maximums per building data
# hits_per_wap_semester_by_building_max <- readRDS("wap_data/rpi_wap_semester_max.Rds")
###CLEANING DATA FOR USAGE IN APP
#rpi_wap_raw: getting devname, users, Date, Building, Hour
rpi_wap_raw <- rpi_wap_raw %>% mutate(Hour = hour(as.POSIXct(time))) %>% select(devname, usercount, Date, Building, Hour)
colnames(rpi_wap_raw) <- c('devname', 'users', 'Date', 'Building', 'Hour')
#getting buildings to append to devnames
bldgs <- rpi_wap_raw %>% filter(Date == min(rpi_wap_last7$Date)+1) %>% filter(Hour==12) %>% select(devname, Building)
# Get maximum number of users for each building
hits_per_wap_semester_by_building_max <- merge(rpi_wap_stats, bldgs, by.x= "devname", by.y="devname")
hits_per_wap_semester_by_building_max <- hits_per_wap_semester_by_building_max %>% group_by(devname, Building, Day) %>% summarise_all(funs(max)) %>% ungroup() %>% select(devname, Day, usercount_max, Building)
hits_per_wap_semester_by_building_max <- hits_per_wap_semester_by_building_max[,2:ncol(hits_per_wap_semester_by_building_max)]
hits_per_wap_semester_by_building_max <- hits_per_wap_semester_by_building_max %>% group_by(Building, Day) %>% summarise_all(funs(sum)) %>% ungroup()
hits_per_wap_semester_by_building_max <- hits_per_wap_semester_by_building_max %>% group_by(Building) %>% summarise_all(funs(max)) %>% ungroup() %>% select(Building, usercount_max)
colnames(hits_per_wap_semester_by_building_max) <- c('Building', 'capacity')
#combined_wap_data: Building, lat, lng
combined_wap_data <- combined_wap_data %>% group_by(Building, latitude, longitude, time, Date) %>% summarise_all(funs(max)) %>% ungroup()
combined_wap_data <- combined_wap_data %>% mutate(Hour = hour(as.POSIXct(time))) %>% filter(Date== min(combined_wap_data$Date)+1) %>% filter(Hour == 12) %>% select(Building, latitude, longitude)
colnames(combined_wap_data) <- c('Building','lat','lng' )
combined_wap_data$BuildingType <- ''
combined_wap_data[combined_wap_data$Building %in% Academic == TRUE, ]$BuildingType <- 'Academic'
combined_wap_data[combined_wap_data$Building %in% Greek == TRUE, ]$BuildingType <- 'Greek'
combined_wap_data[combined_wap_data$Building %in% Housing == TRUE, ]$BuildingType <- 'Housing'
combined_wap_data[combined_wap_data$Building %in% OtherOnCampus == TRUE, ]$BuildingType <- 'OtherOnCampus'
combined_wap_data[combined_wap_data$Building %in% OtherOffCampus == TRUE, ]$BuildingType <- 'OtherOffCampus'