'How to use a shiny app inside rmarkdown file?

How can i add a shiny app inside the rmarkdown file? I have a file named app.r (contains the shiny app) and another file rep.rmd. i saw something like

shinyAppDir(
  system.file("app.R", package = "shiny"),
  options = list(
    width = "100%", height = 550
  )
)

To use the shinyapp inside my rmarkdown file. But it shows this error in console could not find function "shinyAppDir" How can i use my shiny app inside the rmarkdown file?

EDIT:

It's not really a solution as this is more like a workaround, but what i did is to actually put all my files (app.R and report.rmd) into the same folder with the library shiny, and now it detects it. Still, one problem would be that if you have many libraries included in your app.r , it might collapse and terminate R session.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source