How to render a shiny-RMD as HTML Document?

This is my first time dealing with R Markdown and shiny. I've created an RMD which has a chunck with some data that I imported from a RDS document and I've made this data to be interactive using shiny tools (with help from Chat GPT). In my browser the html works perfect, but when i try to create a html_document to send to the team I'm working with, the html is no longer interactive and the data is vanished. Can anybody help me, please? Don't bother the comments in portuguese. Here's the chunk:

  {r Dados, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}

# Configurar um espelho para o CRAN
options(repos = c(CRAN = ""))

# Carregar os dados especĂ­ficos para MoM e YoY
mom_data <- readRDS("C:/Users/MOM.rds")
yoy_data <- readRDS("C:/Users/YOY.rds")

>! Criar interface Shiny com guias
  ui = fluidPage(
      tabPanel("%MoM-sa", value = "MoM",
      tabPanel("%YoY-nsa", value = "YoY",
  server = function(input, output) {
    # Renderizar tabela especĂ­fica para %mom-sa
    output$tabelaMoM <- renderDataTable({
    # Renderizar tabela especĂ­fica para %yoy-nsa
    output$tabelaYoY <- renderDataTable({

To give some information, I have tried to convert it into a html_document using render(mydocument.Rmd, output_format = "html_document", runtime = "shiny"). I also tried to do Ctrl + S in my browser html but it still do not had the data. I have tried all things but nothing seems to work. I don't really know what it is supposed to happen when we "knit" (it became "Run Document" when I started using shiny) the RMD, because when I created it, I did specified that i want a html document as an output and in my console/render does appear a message like "Output created: C:/Users/AppData/Local/Temp/Rtmp253Vw5/file50e87bb9401c/teste1.html" but when i reach out to that file it just does not follow the pattern of the original RMD and it also does not contains the data.

RMarkdown and Shiny are two very specifically different things. You can use them together but you should really first understand what each does on their own:

Shiny needs a server to pull its information from, which in your case is basically your computer. When you send it to other people, they don't have access to your computer, so it does not work for them.

If you just want your plots to be "interactive" in the html, e.g. showing values when hovering over a point, you could also just use plotly or leaflet (for maps).
If you want to make an actual Shiny app which is truly interactive, where users can create different types of maps or visualizations etc (so the script will need to access the data), you need to make sure it has access to a server.

See the Shiny / Posit site on how to do that: Shiny - Share your apps

Thank you for your explanation Geraldine! The server that shiny needed access to wasnt really practical for me and I ended up using the regular "datatable" with some help of javascript codes that made the HTML "interactive". For some reason, plotly didnt work out great for me, not even with ChatGPT help, but thanks for your tips anyway, appreciate it!

1 Like