To set up required packages to create htmlwidget
install.packages("htmlwidgets")
install.packages("devtools")
Scaffolding will provide a template (basic structure) for a widget development
library(devtools)
create("my_widget")
htmlwidgets::scaffoldWidget("my_widget")
document() # Update documentation
build() # Build the package
install()
load_all()
To update any changes:
document()
install()
load_all()
When new functions are created, make sure to add the function in NAMESPACE with roxygen()
#' Description of the cjsInteraction function.
#'
#' @param arg1 Description of the first argument.
#' @param arg2 Description of the second argument.
#'
#' @return Description of the return value.
#'
#' @export
cjsInteraction <- function(arg1, arg2) {
# Function implementation here
}
roxygen2
Debugging htmlwidget
A way to debug what has been generated (javascript blocks) from the html widget, you can execute knitr to see errors or view the generated html page