Skip to content

Commit

Permalink
Adding pielou and interface no longer freezes on Rsampling::Rsampling…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
andrechalom committed Jun 7, 2016
1 parent fbb67f2 commit 1f64661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ shinyServer(function(input, output, session) {
"azteca" = azteca,
"peucetia" = peucetia,
"rhyzophora" = rhyzophora,
"pielou" = pielou,
"upload file" = csvfile())
})
### calculates the distribution of the statistic of interest using Rsampling
Expand Down Expand Up @@ -163,15 +164,18 @@ shinyServer(function(input, output, session) {
vals$iter <- 1
vals$total_iterations <- input$ntrials
vals$seqsim <- seq(100, vals$total_iterations, len=100)
vals$distribution <- Rsampling::Rsampling(type = type, dataframe = data(),
vals$distribution <- tryCatch(
Rsampling::Rsampling(type = type, dataframe = data(),
statistics = statistic(), cols = cols(),
stratum = isolate(stratum()),
ntrials = isolate(input$ntrials),
replace=isolate(input$replace),
progress = pupdate)
progress = pupdate),
error = function (e) 0)
vals$maxcount<-max(hist(vals$distribution, plot=FALSE)$counts)
})
vals$run <- TRUE
if (length(vals$distribution) == vals$total_iterations)
vals$run <- TRUE
# why is resume() called here???
run_iter$resume()
})
Expand Down Expand Up @@ -225,12 +229,14 @@ shinyServer(function(input, output, session) {
### main plot of the program: generates a histogram of distribution()
output$distPlot <- renderPlot({
# Traps errors
if(input$go != 0 && ! vals$run) {
plot(0,0, type='n',xlab="", ylab="", col.main="red", main=tr("Distribution calculation stopped with error!"));
return()
}
if (input$go == 0 | !is.numeric(vals$x)) {
plot(0,0, type='n',xlab="", ylab="", main=tr("Run the resampling to see the graphs"));
return();
}
if (! vals$run)
stop(tr("Distribution calculation stopped with error!"))
Rsampling::dplot(dist = vals$x, svalue = isolate(svalue()), pside= input$pside,
extreme = input$extreme, vline = TRUE, rejection = input$rejection, ylim=c(0,vals$maxcount),
main=tr("distplot_title"), xlab=tr("Statistic of interest"), ylab=tr("Frequency"))
Expand Down
2 changes: 1 addition & 1 deletion ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ shinyUI(fluidPage(theme= "bootstrap.css",
helpText(tr("help1")),
selectInput("datasource",
tr("What is your input data?"),
choices = c("embauba", "azteca", "peucetia", "rhyzophora", "upload file")
choices = c("embauba", "azteca", "peucetia", "rhyzophora", "pielou", "upload file")
),
## the next panel only shows for the custom datasource
fluidRow(column(6,conditionalPanel(
Expand Down

0 comments on commit 1f64661

Please sign in to comment.