r - How to build a shiny style dynamic standalone html page -
i able build nice dynamic reports shiny , markdown/knitr can't share them of coworkers because of security reasons (can't put stuff on company's server, can't set own, , can't send data online).
my reports use ggplot, thought prepare data in neat small tables ready feed plotly , write script build html containing data , plots, , looking same.
i'd keep close shiny local server version.
i thought solution quite complex , hacky:
- write shiny html report, working on neatly prepared data, , standardized format, calling ggplot functions directly
- write script next go through rmd file, extract input types, labels, choices etc along plotting function, parameters , dataset name
- knit file without chunks
- translate (through script) chunks ploty.js, like this
- plug js code in html file
here's example in shiny, i'd have in single html file:
--- title: "iris report" author: "moody_mudskipper" date: '`r sys.date()`' output: html_document runtime: shiny --- ```{r setup, include=false} knitr::opts_chunk$set(echo = false) library(ggplot2) data <- iris # data neatly defined in setup chunk, , not altered later ``` ## title 1 text ```{r chunk1, echo=false} inputpanel( selectinput("species", label = "species:", choices = levels(data$species)), selectinput("metric", label = "metric:", choices = names(data)[1:4]) ) renderplot({ ggplot(subset(data,species==input$species),aes_string(x="species", y=input$metric)) + geom_boxplot() }) ``` ## etc... what way (or close enough) ?
Comments
Post a Comment