I need to include a js library into my Shiny app. Currently I use includeHTML to include the script directly into html codes. e.g.
includeHTML(\'URL.js\')
<
What you need to do is:
www folder in the same folder as server.R and ui.Rwww folder.tags$head(tags$script(src="hoge.js")) in UI.The folder looks like:
├── server.R
├── ui.R
└── www
└── hoge.js
The ui.R is something like
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("New Application"),
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500)
),
mainPanel(
plotOutput("distPlot"),
tags$head(tags$script(src="hoge.js"))
)
))
and server.R
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
dist <- rnorm(input$obs)
hist(dist)
})
})
Note that these are templates generated by Rstudio.
Now head of html looks like:
... snip ...