--- # This is the so called YAML metadata block. Here you can define the title, # author(s) the output format (in our case an html document) and more title: My first R Markdown dokument author: Your Name output: html_document: number_sections: yes highlight: pygments # syntax highlighting toc: yes # show table of content (menu) toc_float: yes # keep ToC on the left runtime: shiny # or shiny_prerendered --- # First Heading Some placeholder text in __bold__, _italic_ and `inline code` style. Let's add inline R Code that is evaluated before the final document is rendered: Today is `r date()`. You can also add a plot using an R code chunks: ```{r, echo=TRUE, eval=TRUE, fig.dim=c(4, 4), fig.align='center'} plot(dist ~ speed, cars) ``` Inside this code chunk you can use normal R syntax. The options add the top (`echo` and `eval`) allow you to specify whether the source code should appear in the rendered document (`echo=TRUE/FALSE` the raw R code is (not) displayed) and whether the code should be evaluated (`eval=TRUE/FALSE`). If `eval=TRUE` is set, all outputs (eg. plots, print, ...) appear in the rendered document. ## Add Shiny elements You can includ any UI part of a Shiny App inside a normal R code chunk. ```{r, echo=FALSE, eval=TRUE} library(shiny) fluidPage( sliderInput("n", "Slider", 1, 10, 5), plotOutput("hist") ) ``` For the server logic however you need to set `context="server"` in the chunk options. ```{r, context="server", echo=FALSE, eval=TRUE} output$hist <- renderPlot({ hist(rnorm(input$n)) }) ```