Skip to content

Commit

Permalink
v1.0.2.9010
Browse files Browse the repository at this point in the history
Revision for staged install, R v3.6.0, Issue #27

Some mods for shiny app (incomplete).  Issue #22
  • Loading branch information
leppott committed May 3, 2019
1 parent 1b85d3b commit 9531fef
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 33 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description: Suite of tools for data manipulation and calculations for Maryland
DNR MBSS program. Includes functions for calculating FIBI, BIBI (MBSS
genus), BIBI (MSW family), PHI, flow sums, ion contributions, and taxa
distribution maps.
Version: 1.0.2.9009
Version: 1.0.2.9010
Authors@R: c(
person("Erik W.", "Leppo", email="Erik.Leppo@tetratech.com", role=c("aut","cre")),
person("Ann","Roseberry Lincoln", role="ctb"),
Expand All @@ -25,3 +25,4 @@ Suggests:
XLConnect
VignetteBuilder: knitr
LazyData: true
StagedInstall: no
11 changes: 10 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ NEWS-MBSStools

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

#> Last Update: 2019-05-01 11:32:11
#> Last Update: 2019-05-03 09:57:54

# MBSStools v1.0.2.9010 (2019-05-01)

- Revise for staged install for R v3.6.0, Issue \#27
- DESCRIPTION
- StagedInstall: no
- Temporary fix. Still needs to be installed from a local file.
- Edits to Shiny App. Issue \#22.
- Incomplete.

# MBSStools v1.0.2.9009 (2019-05-01)

Expand Down
9 changes: 9 additions & 0 deletions NEWS.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ knitr::opts_chunk$set(
cat(paste0("Last Update: ",Sys.time()))
```

MBSStools v1.0.2.9010 (2019-05-01)
================

* Revise for staged install for R v3.6.0, Issue #27
+ DESCRIPTION
- StagedInstall: no
+ Temporary fix. Still needs to be installed from a local file.
* Edits to Shiny App. Issue #22.
+ Incomplete.

MBSStools v1.0.2.9009 (2019-05-01)
================
Expand Down
2 changes: 2 additions & 0 deletions inst/shiny-examples/MBSStools/MetVal.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"","x"
"1","df_import_DT"
1 change: 1 addition & 0 deletions inst/shiny-examples/MBSStools/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Packages
library(shiny)
library(MBSStools)
library(DT)

# Drop-down boxes
#MMIs <- c("BIBI_genus", "BIBI_family", "FIBI")
Expand Down
60 changes: 46 additions & 14 deletions inst/shiny-examples/MBSStools/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Packages
library(shiny)
library(MBSStools)
library(DT)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {
Expand All @@ -35,16 +36,37 @@ shinyServer(function(input, output) {
# sep = input$sep, quote = input$quote)
})##output$df_import~END

output$df_import_DT <- renderDT({
# input$df_import will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.

inFile <- input$fn_input

if (is.null(inFile)){
return(NULL)
}

read.csv(inFile$datapath, header = input$header,
sep = input$sep, quote = input$quote, stringsAsFactors = FALSE)

# read.table(file = inFile$datapath, header = input$header,
# sep = input$sep, quote = input$quote)

})##output$df_import_DT~END

# b_CalcMetVal ####
# Calculate IBI from df_import
observeEvent(input$b_CalcMetVal, {
#
df_data <- 'df_import'
df_data <- 'df_import_DT'

if (is.null(df_data))
return(NULL)

df_data$Person <- "Erik"
#df_data$Person <- "Erik"

write.csv(df_data, "MetVal.csv")

Expand All @@ -53,12 +75,12 @@ shinyServer(function(input, output) {

# myIndex <- input$MMI
# thresh <- MBSStools::metrics_scoring
# myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"Metric"])))
#
# myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"MetricNames.Other"])))
# #
# myCommunity <- Community[match(myIndex, MMIs)]
#
# #
# myMetric.Values <- metric.values(df_data, myCommunity, myMetrics)
#
# #
# return(myMetric.Values)

})##observeEvent~b_CalcIBI~END
Expand All @@ -79,7 +101,7 @@ shinyServer(function(input, output) {

myIndex <- input$MMI
thresh <- MBSStools::metrics_scoring
myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"Metric"])))
myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"MetricName.Other"])))

myCommunity <- Community[match(myIndex, MMIs)]

Expand All @@ -105,7 +127,7 @@ shinyServer(function(input, output) {

myIndex <- input$MMI
thresh <- MBSStools::metrics_scoring
myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"Metric"])))
myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"MetricName.Other"])))

myCommunity <- Community[match(myIndex, MMIs)]

Expand All @@ -127,14 +149,24 @@ shinyServer(function(input, output) {


filename = function() {
paste(input$dataset, "_", format(Sys.time(), "%Y%m%d_%H%M%S"), ".csv", sep = "")
paste(input$dataset, "_", format(Sys.time(), "%Y%m%d_%H%M%S"), ".zip", sep = "")
},
content = function(file) {
write.csv(datasetInput(), file, row.names = FALSE)
# Save Values
# Save Scores
content = function(fname) {##content~START
tmpdir <- tempdir()
setwd(tempdir())
fs <- c("input.csv", "metval.csv", "metsc.csv")
file.copy(inFile$datapath, "input.csv")
file.copy(inFile$datapath, "metval.csv")
file.copy(inFile$datapath, "metsc.csv")
# write.csv(datasetInput(), file="input.csv", row.names = FALSE)
# write.csv(datasetInput(), file="metval.csv", row.names = FALSE)
# write.csv(datasetInput(), file="metsc.csv", row.names = FALSE)

# Create Zip file
}
zip(zipfile = fname, files=fs)
if(file.exists(paste0(fname, ".zip"))) {file.rename(paste0(fname, ".zip"), fname)}
}##content~END
, contentType = "application/zip"
)##downloadData~END

})##shinyServer~END
38 changes: 23 additions & 15 deletions inst/shiny-examples/MBSStools/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Packages
library(shiny)
library(MBSStools)
library(DT)

# Define UI for application that draws a histogram
shinyUI(fluidPage(
Expand All @@ -20,7 +21,23 @@ shinyUI(fluidPage(
# SideBar
sidebarLayout(
sidebarPanel(
h3("1. Load File")
# 0. Progress
h3("App Progress")
, p("1_LoadData, 2_CalcMetrics, 3_CalcIndex, 4_DownloadResults")
, h3("1. Load File")
, h4("Select file parameters")
, checkboxInput('header', 'Header', TRUE)
, radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')
, radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')
#, tags$hr()
, fileInput('fn_input', 'Choose file to upload',
accept = c(
'text/csv',
Expand All @@ -31,19 +48,7 @@ shinyUI(fluidPage(
'.tsv'
)
)##fileInput~END
, tags$hr()
, checkboxInput('header', 'Header', TRUE)
, radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')
, radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')
, tags$hr()
#, tags$hr()
, h3("2. Calculate IBI")
, selectInput("MMI", "Select an IBI to calculate:",
choices=MMIs)
Expand All @@ -57,12 +62,15 @@ shinyUI(fluidPage(
, downloadButton("b_downloadData", "Download")




)##sidebarPanel~END
, mainPanel(
tabsetPanel(type="tabs"
, tabPanel("Directions")
, tabPanel("Data, Import"
, tableOutput('df_import'))
#, tableOutput('df_import'))
, dataTableOutput('df_import_DT'))
, tabPanel("Data, Metric Values"
, tableOutput('df_metric_values'))
, tabPanel("Data, Metric Scores"
Expand Down
3 changes: 1 addition & 2 deletions man/MapTaxaObs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9531fef

Please sign in to comment.