I would like to dynamically create and knit .Rmd
files and display outputs from analysis in browser. I'm using knitr
and knit2html
to do this. Currently I'm using the following approach:
myHTMLsummary <- function(data,x) {
con <- paste0(getwd(),"/myHTMLSummary.Rmd")
writeLines ("
Data frame summary
========================================================
Summary:
```{r,echo=FALSE}
summary(data[x])
```",con)
knit2html(con,quiet=TRUE)
if (interactive()) browseURL(paste0(getwd(),"/myHTMLSummary.html"))
}
myHTMLsummary(iris,"Sepal.Length")
Are there better ways how to dynamically create and knit .Rmd
files or this is the approach anyone is using?
Note: It would be quite cool to have HTML output tab in Rstudio to display results from such function directly (not in external browser). Maybe someone knows how to send results to Help tab?