diable reactive behavior with using selectInput() function in shiny - r

I'm using selectInput in shiny UI for the dropdown option list. however, this one is reactive to my output table.
Can I disable this behaviour? because the table requires several more inputs and additionally I have a run button to trigger it once everything is all set.

Related

Shiny flexdashboard filters after data is loaded

I am creating a flexdashboard that has a sidebar with a dateRangeInput() and an actionButton(). Once the date selection has been made and the button has been clicked I am using observeEvent() to run a SQL query with the selected dates and then display a data table of the results. What I want to do is setup sidebar pickerInput() filters to filter the resulting table however since the data doesn't exist when the app loads this does not work. Is there a way to have the pickerInput() filters load after the data from the query is returned?

Is there a way to slow down the input update from a numericInput ui object

So as the title say I'm looking for a way to slow down the input update form a numericInput ui object.
As a little preface, I am developing an application where I have dynamically built numeric inputs using a map function based on a drop down choice selection of numbers 1-8. So based on how many numeric inputs the user wants to compare the server will dynamically build them. And, in order to display some descriptive statistics, I had to add a actionButton that updates tables built from reactive values.
The problem arises from when I'm looking to type values into the numeric input fields. I only have about 1 second from the initial number click to finish my typing my value until I get kicked out of the numeric input field. In order to finish the number I wish to type I have to click back into the field once or twice to finish typing out the number. Once I have the number typed, I can then hit my action button to update the tables.
How do I make the numeric input fields "sleep" until the button press pulls the values for the reactive tables. I've had to do several odd workarounds due to the nature of the dynamically built numeric inputs and reactive tables/plots. Any input is very welcome.
It's hard to help without some code...
You can do something like that:
go <- reactiveVal(FALSE)
observeEvent(input[["button"]], {
go(TRUE)
})
output[["table"]] <- renderTable({
req(go())
something using the numeric inputs...
})
Does it help?

Shiny dashboard. Hide checkboxes but retain their default value

I have a shinydashboard that I hope to use as a template across several projects. In the side panel I have filters so the user can create a subset of the data, eg gender. I wish to be able to hide certain filters on some projects but still have the output to pass to functions.
For example in ui.r I have
uiOutput("genderGroup")
which I need hiding from view in the dashboard.
In server.r I have
output$genderGroup <- renderUI({
checkboxGroupInput("genderFilter",label=h5("Filter by Gender"),
choices =c("Male"= 1, "Female"= 2),
selected =c(1, 2)
)
})
I still need to capture the output from the genderGroup checkboxes as several reactive functions require the filter as an argument. I've tried hiding the uiOutput with hidden(uiOutput("genderGroup")) in ui.r but the dashboard hangs when trying to look for the value for output$genderFilter.
Note: I'm using the dashboard as a template. I do not want to rewrite functions excluding certain filters on a project by project basis. As data across all projects will contain the same filtered fields, I just want to go in and hide those filters that the project does not need for subsetting. When hidden, the default selected values will be passed to the function.
Thanks
Andrew

Have Highcharts legend update shiny table

I have a shiny app with a sidebarLayout. The offer selection is a checkbox group in the side panel, the highchart is in the main panel with cumulative response rates over time by different offers and finally the table with the current response rate by offer is beneath both the offer checkbox group and cumulative response rate chart.
Ideally I would like to remove the checkboxGroupInput and have the legendItemClick in the highchart take over this functionality so that when a particular offer in the legend is clicked (and no longer visible on the chart) that the corresponding row in the shiny table is also hidden or removed.
I've tried tying the legend item to the checkbox in the shiny checkboxGroupInput, which works here in this JSFiddle, but it does not work with the shiny app.
p1$plotOptions(series=list(stickyTracking=F,
events=list(legendItemClick=paste("#!function(){
if (this.visible) {
$('input[value=",'"',"'+this.name+'",'"',"]').prop('checked',false);
} else {
$('input[value=",'"',"'+this.name+'",'"',"]').prop('checked',true);
}
}!#"))))
Any way I can do this?
Once again, ideally I'd like to replace the checkboxGroupInput with the legendItemClick to update my shiny table.

R shiny gvisTable with columns selected by user in defined order

I have an R shiny webpage where I currently use gvisTable to show a selection of columns from a data.frame. The rows are dynamically selected by the user with the sidebarPanel, but right now the columns are hard-coded inside the gvisTable call.
I would like to allow the user to dynamically select the columns from a drop-down menu (see snapshot of a similar system from a non-shiny webpage). The key feature I want is to allow resorting of the columns.
Any ideas how to pass this sorted selection of columns in shiny?
I don't mind using something else instead of gvisTable if it does the job.
EDIT: Thanks for showing a solution using the sortable answer. It works both for my old and new versions of shiny. Yet, this does not seem to remember the order upon hitting "Refresh", which would be really nice to have.
So, can it save the last chosen order as a browser cookie or a similar way? The server is authenticated, and I've been told I could put the variable order in a list with the user id as the key. An example of that would be great.
In Shiny you would have to use multiple selectInput's. However, you could install ShinySky by ZJ (https://github.com/AnalytixWare/ShinySky) and use his select2 binding which allows sorting. Alternatively, you could modify the sortable binding at https://github.com/mostly-harmless/sortable.
Edit: I don't know about cookies. I use sortable in a larger app. There I have an action button to save the order selected by the user. See Data > Transform > Reorder columns. In the app data is stored in a reactiveValue. To save the data order I use values[[input$datasets]] <- values[[input$datasets]][,input$tr_reorder_cols] where input$datasets is the active dataset, input$tr_reorder_cols is the users selected variable ordering, and values is the reactiveValue that contains the data.
The source for the app is on Github: https://github.com/mostly-harmless/radiant
As an alternative, you could also save the order of the variables in a reactiveValue. See the Shiny documentation for details.
Edit:
In global.R define a reactiveValue:
savedOrder <- reactiveValues()
When a user changes the order (this assumes you have userid available as a variable in R):
if(!is.null(input$sortable)) {
savedOrder[[userid]] <- input$sortable
}
Also, you could pass the id-value to returnOrder in case of a refresh:
if(!is.null(savedOrder[[userid]])) {
returnOrder("sortable",savedOrder[[userid]])
} else {
returnOrder("sortable",colnames(dat))
}

Resources