Skip to content

Commit

Permalink
added control to select examples rather than file input #11
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwhan committed Nov 14, 2016
1 parent d99b9ea commit 277d19d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 10 additions & 4 deletions inst/shiny/granular/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ library(shiny)
library(tidyr)
library(dplyr)
library(scales)
source('../../R/granular.R')
library(shinyjs)
# source('../../R/granular.R')

shinyServer(function(input, output, session) {

Expand All @@ -13,6 +14,11 @@ shinyServer(function(input, output, session) {
}
})

observe({
toggle('select_data', condition = input$use_example)
toggle('file', condition = !input$use_example)
})

getData <- reactive({
inFile <- input$file
if (is.null(inFile))
Expand Down Expand Up @@ -83,11 +89,11 @@ shinyServer(function(input, output, session) {
incProgress(1/(n - 1),
"Calculating...",
paste("working on",
names(tData)[i],
names(tData)[i + 1],
"which is",
i - 1, "of", n - 1)
i, "of", n - 1)
)
newfit <- mix_dist(tData[[i + 1]], ps,
newfit <- granular::mix_dist(tData[[i + 1]], ps,
names(tData)[i + 1], comp_means = means)
output_list[[i]] <<- newfit[[1]]
output_df <<- bind_rows(output_list)
Expand Down
12 changes: 8 additions & 4 deletions inst/shiny/granular/ui.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
library(shiny)
source('../../R/granular.R')
library(shinyjs)

mastersizer_vis <- function(outputId) {
HTML(paste("<div id=\"", outputId, "\" class=\"shiny-network-output\"><svg width=500 height=500> </svg></div>", sep=""))
}

shinyUI(fluidPage(

useShinyjs(),
tags$head(
tags$script(src="//d3js.org/d3.v4.js"),
tags$link(rel = 'stylesheet', type = 'text/css', href = 'custom.css'),
Expand All @@ -30,8 +30,12 @@ shinyUI(fluidPage(
tags$div(class = 'row-fluid',
fileInput('file', 'Choose CSV file', accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')))
)
'.csv'))),
tags$div(class = 'row-fluid',
selectInput("select_data", "Select data", c("Single sample", "Three samples", "Thirty-six samples"))),
tags$div(class = 'row-fluid',
checkboxInput('use_example', 'Use example data'))
)
),
actionButton("goButton", "Go!"),

Expand Down

0 comments on commit 277d19d

Please sign in to comment.