r - Revealing text in a shiny document -


in interactive document, possible use block of shiny code hide/reveal markdown?

a simple example of i'd is:

--- title: "example" output: html_document runtime: shiny --- $2+2$?  ```{r reveal, echo=false} actionbutton("button", "reveal solution") #try (unsuccessfully) comment out rest of document renderui(html(ifelse(input$button, "", ("<!--")))) ```  answer $4$. 

in real use case question , answer long , both involve shared randomly generated r variables.

here code should work you:

--- title: "example" output: html_document runtime: shiny --- $2+2$?  ```{r reveal, echo=false} library(shiny) actionbutton("button", "reveal solution") #try (unsuccessfully) comment out rest of document rendertext({if(input$button == 0) {null }else{ print("the answer 4")}}) ``` 

if understood correctly wanted solution of 2 + 2 after pressing actionbutton, therefore have used if...else... statement saying if value of actionbutton == 0, should return null, else text: the answer 4 should printed.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -