Skip to content

Instantly share code, notes, and snippets.

@trestletech
Created April 17, 2014 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trestletech/10993312 to your computer and use it in GitHub Desktop.
Save trestletech/10993312 to your computer and use it in GitHub Desktop.
includeRmd in Shiny
---
title: "hidden"
output: html_document
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
shinyServer(function(input, output) {
})
library(knitr)
includeRmd <- function(path){
contents <- paste(readLines(path, warn = FALSE), collapse = '\n')
html <- knit2html(text = contents, fragment.only = TRUE, options=c("use_xhtml","smartypants","mathjax","highlight_code", "base64_images"))
Encoding(html) <- 'UTF-8'
HTML(html)
}
shinyUI(fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
tabsetPanel(
tabPanel("tab1",
includeHTML("test2.html")),
tabPanel("tab2",
includeRmd("hidden.Rmd"))
)
)
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment