shinyWidgets::sliderTextInput

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

shinyWidgets::sliderTextInput

Sigbert Klinke
Hi,

I'am using

sliderTextInput('myinput', choices=list("choice1"=1, "choice2"=2,
"choice3"=3))

But in the shiny app the UI element shows '1', '2', instead of
'choice1', 'choice2' etc.

I think the reason is that in shinyTextInput is done

     if (!is.character(choices)) {
         choices <- as.character(choices)
     }

Any idea if I could achieve my wished behaviour?

Best Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shinyWidgets::sliderTextInput

Eric Berger
Hi Sigbert,

Just leave out the '=...', as in

sliderTextInput('myinput', choices=list("choice1", "choice2", "choice3") )

HTH,
Eric



On Tue, Aug 6, 2019 at 10:52 AM Sigbert Klinke <[hidden email]>
wrote:

> Hi,
>
> I'am using
>
> sliderTextInput('myinput', choices=list("choice1"=1, "choice2"=2,
> "choice3"=3))
>
> But in the shiny app the UI element shows '1', '2', instead of
> 'choice1', 'choice2' etc.
>
> I think the reason is that in shinyTextInput is done
>
>      if (!is.character(choices)) {
>          choices <- as.character(choices)
>      }
>
> Any idea if I could achieve my wished behaviour?
>
> Best Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shinyWidgets::sliderTextInput

Erin Hodgess-2
In reply to this post by Sigbert Klinke
Hi Sigbert:

Is there a label argument, please? I think that might be it.

Thanks,
Erin

On Tue, Aug 6, 2019 at 1:52 AM Sigbert Klinke <[hidden email]>
wrote:

> Hi,
>
> I'am using
>
> sliderTextInput('myinput', choices=list("choice1"=1, "choice2"=2,
> "choice3"=3))
>
> But in the shiny app the UI element shows '1', '2', instead of
> 'choice1', 'choice2' etc.
>
> I think the reason is that in shinyTextInput is done
>
>      if (!is.character(choices)) {
>          choices <- as.character(choices)
>      }
>
> Any idea if I could achieve my wished behaviour?
>
> Best Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Erin Hodgess, PhD
mailto: [hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shinyWidgets::sliderTextInput

Sigbert Klinke
Hi,

> Is there a label argument, please? I think that might be it.

In my example I had a label, but this not the problem since

 > choices=list("choice1"=1, "choice2"=2,"choice3"=3)
 > as.character(choices)
[1] "1" "2" "3"

delivers the result as it is used in sliderTextInput. I was hoping there
was a way to bypass that behaviour without changing the sliderTextInput
function ;)
The default action of selectInput using a list for choices is to show in
the UI element the list names, but to deliver to the shiny app the
number if one is selected.

Thanks Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shinyWidgets::sliderTextInput

Erin Hodgess-2
Hi Sigbert


Here is something that has both the sliderTextInput and Radio Buttons,
which may be helpful:

library("shiny")

library("shinyWidgets")


ui <- fluidPage(

  br(),

  sliderTextInput(

    inputId = "mySliderText",

    label = "My House",

    choices = list("choice 1" = "choice 1","choice 2" ="choice 2",

    "choice 3" ="choice 3"),

    selected = "choice 1"

  ),


          radioButtons(inputId="slope", label="Radio Buttons",

               choices=list("Choice 1" = "Choice 1","Choice 2" = "Choice 2",

                 "Choice 3" = "Choice 3")),



  verbatimTextOutput(outputId = "result")

)


server <- function(input, output, session) {

  output$result <- renderPrint({

  str(input$mySliderText)

  str(input$slope)

}

)


}


shinyApp(ui = ui, server = server)



Hope this helps!


Sincerely,

Erin



Erin Hodgess, PhD
mailto: [hidden email]


On Wed, Aug 7, 2019 at 6:31 AM Sigbert Klinke <[hidden email]>
wrote:

> Hi,
>
> > Is there a label argument, please? I think that might be it.
>
> In my example I had a label, but this not the problem since
>
>  > choices=list("choice1"=1, "choice2"=2,"choice3"=3)
>  > as.character(choices)
> [1] "1" "2" "3"
>
> delivers the result as it is used in sliderTextInput. I was hoping there
> was a way to bypass that behaviour without changing the sliderTextInput
> function ;)
> The default action of selectInput using a list for choices is to show in
> the UI element the list names, but to deliver to the shiny app the
> number if one is selected.
>
> Thanks Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: shinyWidgets::sliderTextInput

Sigbert Klinke
Hi Erin,

do you see the difference between sliderTextInput and selectInput? I
would like to have the selectInput behaviour (list element name in
display, but result as value of list element) in sliderTextInput as well.

Best Sigbert

---

library("shiny")
library("shinyWidgets")

ui <- fluidPage(
   br(),
   sliderTextInput(
     inputId = "mySliderText",
     label = "My House",
     choices = list("choice 1" = 1,"choice 2" =2,
                    "choice 3" = 3)
   ),
   selectInput(inputId="slope", label="selectInput",
                choices=list("Choice 1" = "A","Choice 2" = "B",
                             "Choice 3" = "C")),
   verbatimTextOutput(outputId = "result")
)


server <- function(input, output, session) {

   output$result <- renderPrint({
     str(input$mySliderText)
     str(input$slope)
   })
}

shinyApp(ui = ui, server = server)


--
https://hu.berlin/sk
https://hu.berlin/mmstat3

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.