Skip to content

Instantly share code, notes, and snippets.

@stla
Last active December 26, 2015 11:39
Show Gist options
  • Select an option

  • Save stla/7144955 to your computer and use it in GitHub Desktop.

Select an option

Save stla/7144955 to your computer and use it in GitHub Desktop.
Shiny Session Report - v0
includeRmd <- function(path){ # https://groups.google.com/d/topic/shiny-discuss/ObgFdmusyJM/discussion
if (!require(knitr))
stop("knitr package is not installed")
if (!require(markdown))
stop("Markdown package is not installed")
shiny:::dependsOnFile(path)
contents = paste(readLines(path, warn = FALSE), collapse = '\n')
html <- knitr::knit2html(text = contents, fragment.only = TRUE)
Encoding(html) <- 'UTF-8'
return(HTML(html))
}
library(shiny)
library(knitr)
library(markdown)
shinyServer(function(input, output) {
output$sessioninfo <- renderUI({
if(!is.null(input$packages)) sapply(input$packages, function(x) eval(parse(text=paste0("library(",x,")"))))
includeRmd("SessionInfo.Rmd")
})
})
```{r sessionInfo, echo=FALSE}
si <- sessionInfo()
opkgver <- sapply(si$otherPkgs, function(x) x$Version)
nspkgver <- sapply(si$loadedOnly, function(x) x$Version)
opkgver <- opkgver[sort(names(opkgver))]
nspkgver <- nspkgver[sort(names(nspkgver))]
verso <- paste("(v", opkgver, ")", sep = "")
versns <- paste("(v", nspkgver, ")", sep = "")
```
### Session Information
**Version:** `r si$R.version$version.string`
- Platform: `r si$R.version$platform`
- Locale: `r si$locale`
**Packages:**
- Base: `r paste(sort(si$basePkgs), collapse = ", ")`
- Other: `r paste(names(opkgver), verso, sep = " ", collapse = ", ")`
- Loaded (not attached): `r paste(names(nspkgver), versns, sep = " ", collapse = ", ")`
**Session Details**
- Working directory: `r getwd()`
shinyUI(pageWithSidebar(
headerPanel("Shiny session report"),
sidebarPanel(
checkboxGroupInput("packages", "Load package:",
choices=as.list(rownames(installed.packages())[1:10])
),
HTML("<hr />"),
helpText(HTML("<p> >>><a href = \"https://gist.github.com/stla/7144955\">source code</a><<<"))
),
mainPanel(
uiOutput("sessioninfo")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment