On Wed, Dec 14, 2016 at 12:25 PM, Ali Al-Hadab <
ali.a...@gmail.com> wrote:
> Here is a quick example
>
> library(shiny)
> shinyApp(
> ui = fluidPage(
> column(2,
> checkboxInput(inputId = "mpg",label = "mpg", value = F),
> checkboxInput(inputId = "cly",label = "cyl", value = F)),
> column(8,tableOutput("out"))
> ),
>
> server = function(input, output) {
> output$out = renderTable({
> mtcars %>% gather_(key,value,input$mpg,input$cyl)
> })
> }
> )
You seem to expect checkboxInput to give you the label associated with
it, but that's not what ?checkboxInput says. It gives TRUE for the
ones that are checked and FALSE for the ones that are not.
checkboxGroupInput appears to do what you want:
shinyApp(
ui = fluidPage(
column(2,
checkboxGroupInput(inputId = "variable",
label = "variables:",
choices = c(mpg = "mpg", cyl = "cyl"))),
column(8,tableOutput("out"))
),
server = function(input, output) {
output$out = renderTable({
mtcars %>% gather_("key","value", gather_cols = input$variable)
})
}
)
>
> I also wonder if it is possible to keep columns as they are and change the
> format for the chosen columns only
I don't understand the question. Can you clarify?
Best,
Ista
>
> Thanks
>
>
> On Wednesday, December 14, 2016 at 9:36:41 AM UTC-6, Ali Al-Hadab wrote:
>>
>> I am trying to use tidyr::gather function in a shiny app for the option
>> for Appuser to choose which columns.
>>
>> data %>% gather(Key, Value, user choices) and choices are checkboxes.
>>
>> I have not been able to do so and I appreciate the help with that.
>>
>> Thanks
>