#' Shiny Application for Exploring Processed Datasets
#'
#' Launches METsteps Shiny application for interactively exploring datasets, producing statistics, and longer-term,
#' calculating a national water budget.
#'
#' @param path.feather Character; Path to folder containing feather files produced through zooHUCtoFeather
#' @param path.obsMeta Character; Path to metadata file. Defaults to NULL.
#' @param path.obs Character; Path to folder containing point data observation files as listed in metadata file.
#' @export
#' @return Shiny application
#' @examples
#' exploreShiny()
exploreShiny <- function(path.feather,
path.obsMeta = NULL,
path.obs = NULL){
require(dplyr)
require(feather)
require(hydroGOF)
require(leaflet)
require(lubridate)
require(METsteps)
require(parallel)
require(raster)
require(scales)
require(shiny)
require(shinyBS)
require(shinydashboard)
require(stringr)
require(viridis)
require(zoo)
if (length(path.feather) > 1) stop('Please submit only a single folder directory path.')
path.feather <<- path.feather
fnames.feather <<- list.files(path = path.feather,
pattern = '\\.feather$',
full.name = FALSE)
fileInfo <<- extractMetadata(METname = fnames.feather,
df = T)
fileInfo <<- data.frame(fnames = fnames.feather,
fileInfo,
stringsAsFactors = FALSE)
fileInfo$startDate <- as.Date(fileInfo$startDate)
fileInfo <<- fileInfo
# Map constraints
bounds <<- c(-124.8, 23.4, -67, 45 )
states <<- METsteps::stateLines
# Set Seasons
All <<- (1:12)
Fall <<- c(9, 10, 11)
Winter <<- c(12, 1, 2)
Spring <<- c(3, 4, 5)
Summer <<- c(6, 7, 8)
# Get obs metadata
if (!is.null(path.obsMeta)){
ptmeta <<- read.csv(file = path.obsMeta,
stringsAsFactors = F)
if (colnames(ptmeta)[1] == 'X') ptmeta <<- ptmeta[,-1]
ptmeta$Source[is.na(ptmeta$Source)] <<- 'NA'
timeStep <<- NULL
ptmeta.map <<- NULL
if (METsteps::substrRight(path.obs) != '/'){
path.obs <<- paste0(path.obs, '/')
}else{
path.obs <<- path.obs
}
}else{
ptmeta <<- NULL
ptmeta.map <<- NULL
}
# Check to make sure observational data folder exists
if (!is.null(path.obs)){
if (!dir.exists(path.obs)) stop("path.obs does not exist.")
}else{
path.obs <<- NULL
}
# Initiate application
shiny::runApp(appDir = system.file('exploreShiny',
package = 'METsteps'))
}
#METsteps::exploreShiny(path.feather = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/FeatherFiles', path.obsMeta = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/PointData/ET/New/metadata.csv', path.obs = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/PointData/ET/New/')
# METsteps::exploreShiny(path.feather = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/FeatherFiles',
# path.obsMeta = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/PointData/ET/metadata/metadata.csv',
# path.obs = 'C:/Users/ssaxe/Documents/Projects/Model Evaluation/RShiny/PointData/ET/New2/')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.