Tidyr::gather in shiny App

89 ዕይታዎች
ወደ የመጀመሪያው ያልተነበበ መልዕክት ዝለል

Ali Al-Hadab

ያልተነበበ፣
14 ዲሴም 2016 10:36:41 ጥዋት14/12/2016
ለ manipulatr
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

Ista Zahn

ያልተነበበ፣
14 ዲሴም 2016 11:19:42 ጥዋት14/12/2016
ለ Ali Al-Hadab፣manipulatr
Hi Ali,

Right now the pool of people who can answer your question is limited
to those who a) know the answer off the top of their head or b) have
the time and inclination to write and test an example themselves. If
you make a small reproducible example the pool of people able to help
you will dramatically increase to all those who are able to tweak your
example to make it work.

Best,
Ista
> --
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to manipulatr+...@googlegroups.com.
> To post to this group, send email to manip...@googlegroups.com.
> Visit this group at https://groups.google.com/group/manipulatr.
> For more options, visit https://groups.google.com/d/optout.

Ali Al-Hadab

ያልተነበበ፣
14 ዲሴም 2016 12:25:21 ከሰዓት14/12/2016
ለ manipulatr
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)
    })
  }
)

I also wonder if it is possible to keep columns as they are and change the format for the chosen columns only

Thanks

Ista Zahn

ያልተነበበ፣
14 ዲሴም 2016 12:49:15 ከሰዓት14/12/2016
ለ Ali Al-Hadab፣manipulatr
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
>
ለሁሉም ምላሽ ስጥ
ለፀሃፊው መልስ ስጥ
አስተላልፍ
0 አዲስ መልዕክቶች