0

I’m working in a R notebook and I’d like to add some interactivity using shiny. So, I need that the user provide some text in an input field. Then, this text will used in different R chunks in the notebook. However, I wasn’t able to find the best way to do this. Here is an example of what I’m trying to do:

---
title: "R Notebook"
output: html_document
runtime: shiny
---


```{r}
data <- reactive({
    as.character(input$my_mol)
})

```


```{r}
textInput("my_mol", "Please provide an ID", "MyID_1")
```


```{r}
renderPrint(data())

# is there any way to get the text output in a variable and using it in a different R chunk?
#something like: 
#my_output <- renderPrint(data())

```

```{r}
# Then, I'd like to using it on this R chunk
#pba3 <- fromJSON(paste0(baseur_sim, url_encode(my_output), ".json?limit=50"), flatten=TRUE)
```

Thanks!

Vishesh Shrivastav
  • 2,079
  • 2
  • 16
  • 34
ASC
  • 1
  • 1
  • You might want to check out this post. https://shiny.rstudio.com/reference/shiny/1.0.3/applyInputHandlers.html – as26 Nov 02 '18 at 14:42
  • This app from the Shiny Gallery should get you started: https://shiny.rstudio.com/gallery/generating-reports.html – tblznbits Nov 02 '18 at 14:43

0 Answers0