Addins: Initiate drake -> drake$source_plan()
-> drake$makePlan()
.
web$browse()
to see the output.
If any change to Rmd, save the Rmd, then drake$update()
-> web$browser()
to see the change.
Your html output file is in web$output_filepath()
.
library(dplyr) library(htmltools) library(econR) .GlobalEnv$web <- econR::Web() web$foldername="docs2" # output folder name web$html_filename <- "index.html"
Widgets can be designed in a separate file and saved in a Rdata for loading here.
While loading, make sure envir = .GlobalEnv
.
Label widget loading chunk makecondition_xxx
.
library(plotly)
plt_widget <- subplot( plot_ly(mpg, x = ~cty, y = ~hwy, name = "default"), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(alpha = 0.2, name = "alpha") )
el_widget <- tags$div(class="container", tags$div(class="row", tags$div(class="col s12", plt_widget) ))
main <- tags$main( tags$h5(class="center-align", "Materialise with Plotly") )
bodyTagList <- { htmltools::tagList( main, el_widget ) }
html_placeholder <- tags$html( tags$head( do.call(htmltools::tagList, headTags), tags$meta( name="viewport", content="width=device-width, initial-scale=1.0" ) ), tags$body( bodyTagList #do.call(htmltools::tagList, bodyTags) ) )
headTags <- { htmltools::tagList( htmltools::tags$link( href="https://fonts.googleapis.com/icon?family=Material+Icons", rel="stylesheet" ) ) }
myDependency <- htmltools::htmlDependency( name="myown", version="1.0", src=c(filepath=web$cssJsPath), stylesheet = "css/mystyle.css", script = "js/mydesign.js", head = '<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+TC"> ' )
web$config_cssJsPath("your_path")
in makecondition -- no need to change web$cssJsPath
(it will change accordingly).local_jquery <- htmltools::htmlDependency( name="jquery", version="3.5.1", src=c(href = "lib/jquery-3.5.1"), # to use the same library here must use href, not filepath; otherwise, the current jquery system will be removed. script = c("jquery.min.js") )
html_complete <- htmltools::tagList( html_placeholder, web$htmlDependencies$materialise(), local_jquery, myDependency )
local_jquery
with web$htmlDependencies$jquery()
htmltools::save_html( html_complete, file = web$output_filepath(), libdir="lib" )
web$browse()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.