Below is my code snippet from a Quarto doc. if extracted into a shinyApp, see second section below it works just fine. If I run this as a quarto doc, I get an error:
Warning: Error in %>%: could not find function "%>%"
5:
3: rmarkdown::run
2: run
1: .main
Can Quarto handle the magrttr pipe? Unsure why this won't run.
title: "anothertest"
format: html
server: shiny
Shiny Documents
This Quarto document is made interactive using Shiny. Interactive documents allow readers to modify parameters and see the results immediately. Learn more about Shiny interactive documents at https://quarto.org/docs/interactive/shiny/.
Inputs and Outputs
You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive:
library(tidyverse)
actionButton('but',label = 'Click')
selectInput('sel', label = 'select',choices = NULL)
verbatimTextOutput('out')
#| context: server
observeEvent(input$but,{
updateSelectInput(session = session,inputId = 'sel',
choices = mtcars %>% rownames_to_column() %>% as_tibble() %>% distinct(rowname) %>% pull())
})
output$out <- renderPrint(input$sel)
Shiny App
library(shiny)
ui <- fluidPage(
actionButton('but',label = 'Click'),
selectInput('sel', label = 'select',choices = NULL),
verbatimTextOutput('out')
)
server <- function(input, output, session) {
observeEvent(input$but,{
updateSelectInput(session = session,inputId = 'sel',
choices = mtcars %>% rownames_to_column() %>% as_tibble() %>% distinct(rowname) %>% pull())
})
output$out <- renderPrint(input$sel)
}
shinyApp(ui, server)