From 9531fef738fc9d0554a74df3cade77a80217af9b Mon Sep 17 00:00:00 2001 From: leppott Date: Fri, 3 May 2019 09:59:39 -0400 Subject: [PATCH] v1.0.2.9010 Revision for staged install, R v3.6.0, Issue #27 Some mods for shiny app (incomplete). Issue #22 --- DESCRIPTION | 3 +- NEWS | 11 ++++- NEWS.rmd | 9 ++++ inst/shiny-examples/MBSStools/MetVal.csv | 2 + inst/shiny-examples/MBSStools/global.R | 1 + inst/shiny-examples/MBSStools/server.R | 60 ++++++++++++++++++------ inst/shiny-examples/MBSStools/ui.R | 38 +++++++++------ man/MapTaxaObs.Rd | 3 +- 8 files changed, 94 insertions(+), 33 deletions(-) create mode 100644 inst/shiny-examples/MBSStools/MetVal.csv diff --git a/DESCRIPTION b/DESCRIPTION index 6bbf330..f694ea4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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"), @@ -25,3 +25,4 @@ Suggests: XLConnect VignetteBuilder: knitr LazyData: true +StagedInstall: no diff --git a/NEWS b/NEWS index d836a63..49766e4 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,16 @@ NEWS-MBSStools - #> 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) diff --git a/NEWS.rmd b/NEWS.rmd index 30fb824..6d10d42 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -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) ================ diff --git a/inst/shiny-examples/MBSStools/MetVal.csv b/inst/shiny-examples/MBSStools/MetVal.csv new file mode 100644 index 0000000..e2cce5d --- /dev/null +++ b/inst/shiny-examples/MBSStools/MetVal.csv @@ -0,0 +1,2 @@ +"","x" +"1","df_import_DT" diff --git a/inst/shiny-examples/MBSStools/global.R b/inst/shiny-examples/MBSStools/global.R index abe55d1..4355b81 100644 --- a/inst/shiny-examples/MBSStools/global.R +++ b/inst/shiny-examples/MBSStools/global.R @@ -3,6 +3,7 @@ # Packages library(shiny) library(MBSStools) +library(DT) # Drop-down boxes #MMIs <- c("BIBI_genus", "BIBI_family", "FIBI") diff --git a/inst/shiny-examples/MBSStools/server.R b/inst/shiny-examples/MBSStools/server.R index 039165b..b5ed5be 100644 --- a/inst/shiny-examples/MBSStools/server.R +++ b/inst/shiny-examples/MBSStools/server.R @@ -10,6 +10,7 @@ # Packages library(shiny) library(MBSStools) +library(DT) # Define server logic required to draw a histogram shinyServer(function(input, output) { @@ -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") @@ -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 @@ -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)] @@ -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)] @@ -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 diff --git a/inst/shiny-examples/MBSStools/ui.R b/inst/shiny-examples/MBSStools/ui.R index 888becd..4ab4dbd 100644 --- a/inst/shiny-examples/MBSStools/ui.R +++ b/inst/shiny-examples/MBSStools/ui.R @@ -10,6 +10,7 @@ # Packages library(shiny) library(MBSStools) +library(DT) # Define UI for application that draws a histogram shinyUI(fluidPage( @@ -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', @@ -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) @@ -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" diff --git a/man/MapTaxaObs.Rd b/man/MapTaxaObs.Rd index c3147cd..8f8452b 100644 --- a/man/MapTaxaObs.Rd +++ b/man/MapTaxaObs.Rd @@ -5,8 +5,7 @@ \title{Taxa Observation Maps} \usage{ MapTaxaObs(obs, xWalk, dirMain = getwd(), onlymatches = TRUE, - dirData = "Data", dirGIS = "GIS", dirMaps = "Maps", - verbose = TRUE) + dirData = "Data", dirGIS = "GIS", dirMaps = "Maps", verbose = TRUE) } \arguments{ \item{obs}{Excel file containing 3 columns: TaxaName, Latitude83, Longitude83}