Skip to content
Permalink
Browse files
Adding Initial Files
  • Loading branch information
knissk committed Nov 23, 2020
1 parent 91b4c5c commit 164c9b3b5ccf60158b2ac56cfa5faa5f1404c3ac
Show file tree
Hide file tree
Showing 19 changed files with 1,924 additions and 0 deletions.
832 app.R

Large diffs are not rendered by default.

BIN +45.9 KB images/WithoutBlue.png
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.
BIN +20.9 KB images/beige_star.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +21.7 KB images/blue_star.png
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,0 +1,65 @@
#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'
@@ -0,0 +1,106 @@
#Reading in the data and necessary libraries and data 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(plyr)
library(scales)
library(zoo)
library(ggalt)
library(leaflet)
library(plotly)
library(wesanderson)
library(reactable)

################################################################################################################
###READING IN NECESSARY FILES
################################################################################################################
#rpi_wap_raw: Min_30, devname, maccount, usercount, datetime, date_time, Date, Building, Floor, Room, latitude, longitude, buldingType, abbrev, time
rpi_wap_raw <- readRDS("../../COVID_RPI_WiFi_Data/rpi_wap_raw.rds")

#combined_wap_data: building, time, Date, latitude, longitude, buildingType, abbrev, users, macs,
combined_wap_data <- readRDS("../../COVID_RPI_WiFi_Data/combined_wap_data.rds")

#rpi_wap_stats: devname, Day, maccount_mean, maccount_med, maccount_max, usrecount_mean, usercount_med, usercount_max
rpi_wap_stats <- readRDS("../../COVID_RPI_WiFi_Data/rpi_wifi_semester_day_summary.rds")

#rpi_wap_week: devname, maccount, usercount, datetime, date_time, Date, Day
rpi_wap_week <- readRDS("../../COVID_RPI_WiFi_Data/rpi_wifi_semester_extended.rds")

#buildinginfo: Building, latitude, longitude, buildingType, abbrev
#buildinginfo <- readRDS("../../COVID_RPI_WiFi_Data/buildinginfo.rds")

################################################################################################################
###CLEANING DATA
################################################################################################################
#rpi_wap_raw: devname, users, Date, Building, Hour, lat, lng, BuildingType
rpi_wap_raw <- rpi_wap_raw %>% mutate(Hour = hour(as.POSIXct(time))) %>% select(devname, usercount, Date, Building, Hour, latitude, longitude, buildingType)
colnames(rpi_wap_raw) <- c('devname', 'users', 'Date', 'Building', 'Hour', 'lat', 'lng', 'BuildingType')

#combined_wap_data: Building, Hour, lat, lng, BuildingType
rpi_wap_last7 <- combined_wap_data %>% mutate(Hour = hour(as.POSIXct(time))) %>% select(Building, users, Date, Building, Hour, latitude, longitude, buildingType)
rpi_wap_last7 <- rpi_wap_last7 %>% group_by(Building, Date, Hour, latitude, longitude, buildingType) %>% summarise_all(funs(max)) %>% ungroup()
colnames(rpi_wap_last7) <- c('Building', 'Date', 'Hour','lat','lng', 'BuildingType', 'users' )

#Building Tagging, Use Later for whatever categories we have
#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'

#bldgs(getting buildings to append to devnames): devname, Building
bldgs <- rpi_wap_raw %>% filter(Date == min(rpi_wap_last7$Date)+1) %>% filter(Hour==12) %>% select(devname, Building)

# hits_per_wap_semester_by_building_max(getting maximum number of users for each building): Building, capacity
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')

################################################################################################################
## DEFININING LISTS AND DATA FRAMES FOR CONVENIENCE
################################################################################################################

#Possible tagging for later
#placesOfInterest <- c('CII', 'DCC', 'Folsom Library', 'Rensselaer Union', 'Voorhees Computing Center')
#placesOfWellness <- c('ASRC', 'ECAV arena', 'ECAV stadium', 'Houston Field House', 'Fitness Center', '87 Gym', 'Robison Pool')
#placesOfDeliciousness <- c('Moes, College Ave', 'Commons Dining Hall', 'Russell Sage Dining Hall')
#BuildingTypes <- c('Academic','Housing','placesOfInterest', 'placesOfWellness', 'placesOfDeliciousness', 'Greek', 'OtherOnCampus', 'OtherOffCampus')

#creating a time list for the graphs so they aren't in military time
time <- list('12:00am'= 0,'1:00am'=1, '2:00am'=2, '3:00am'=3, '4:00am'=4, '5:00am'=5, '6:00am'=6, '7:00am'=7, '8:00am'=8, '9:00am'=9, '10:00am'=10, "11:00am"=11, "12:00pm"=12, "1:00pm"=13, "2:00pm"=14, "3:00pm"=15, "4:00pm"=16, "5:00pm"=17, "6:00pm"=18, "7:00pm"=19, "8:00pm"=20, "9:00pm"=21,"10:00pm"=22, "11:00pm"=23)
Time_num <- c(0:23)
Time_AMPM <- c('12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am', '12pm', '1pm', '2pm','3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm' )
Time_noLabel <- c(12,1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11)
time.data <- data.frame(Time_num, Time_AMPM, Time_noLabel, stringsAsFactors=FALSE)

#defining the max date and min date info
min_date <- min(rpi_wap_last7$Date)
max_date <- max(rpi_wap_last7$Date)
max_time_of_max_date <- max(rpi_wap_last7[rpi_wap_last7$Date == max(rpi_wap_last7$Date),]$Hour)+1
min_time_of_min_date <- min(rpi_wap_last7[rpi_wap_last7$Date == min(rpi_wap_last7$Date),]$Hour)+1

#weekday information
#getting selected weekday
day <- c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" )
dayVal<- c(1,2,3,4,5,6,7)
weekpair <- data.frame(day,dayVal, stringsAsFactors=FALSE)

#weekly3_stats(Getting average devname users of the last three weeks by day): devname, Day, Hour, users
weekly3_stats <- rpi_wap_week %>% filter(Date >= min(rpi_wap_last7$Date)-21) %>% mutate(Hour = hour(as.POSIXct(date_time)))
weekly3_stats <- weekly3_stats %>% select(devname, usercount, Day, Hour) %>% group_by(devname, Day, Hour) %>% summarise_all(funs(max)) %>% ungroup()
colnames(weekly3_stats) <- c('devname', 'Day', 'Hour', 'users')

BIN +6.71 KB www/Rensselaer.png
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 164c9b3

Please sign in to comment.