27.    R - markdown, Package shiny

October 22, 2018
home

Contents

01. Ways to use the data or/and plots from R code, not R markdown.

02. What is R markdown?

lab 1 - markdown code only

        ---
        title: "My First Markdown"
        author: "Peter Kao"
        date: "10/19/2018"
        output: html_document
        ---
            

lab 2 - R code chucks in R mark down

        ---
        title: "My Second Markdown"
        author: "Peter Kao"
        date: "10/20/2018"
        output: slidy_presentation
        ---
            
        There are 5 slides generated from the sample code.
        slide 1:    preamble information
        
        slide 2:    ## R Markdown
                    This is....
                    ....
                     
            note 2.1: Slides are separated by heading 1 with ## preface.
            note 2.2: Some descriptive texts are for this markdown.

        slide 3:    ## Slide with BulletsView 
            note 3.1: markdown code           

        slide 4:    ```{r cars, echo = TRUE}
                    summary(cars)
                    ```

            note 4.1  R code chunk 
            note 4.2  cars inside {} is the R code chunk name.
            note 4.3  cars in function summary is the data set name.
            note 4.4  The code echo is set to TRUE, the code will be diaplayed.
            note 4.5  A statistical data is presented.   
            
            note 4.6  It is diaplay in a client-side browser.
            note 4.7  R markdown code is evaluated with R makdown interpretator.
            note 4.8  R code chunks is evaluated with R interpretator.
            note 4.9  This is nothing to do with any web server.
            

        slide 5:        ```(r presure}
                        plot(presure)
                        ```

            note 5.1  R code chunk 
            note 5.2  presure inside {} is the R code chunk name.
            note 5.3  presure in function plot is the data set name.  
            note 5.4  A plot is presented.
                

03. What is package shiny

04. demo - One R markdown chunk, shiny, presentation

            code review 1 - preamble
            
                ---
                ...
                runtime: shiny
                ---  
            
            1. A user requests this RMD file.
            2. The RMD file reaches the server site for R, shiny.
            3. In the server, the corresponding html, js,css files are created from the RMD file.
            3. There is no knit for static contents.
            4. When you create the Rmd file, the property of runtime is set to shiny in preamble by the RStudio, not default.
                
            code review 2 - R code chunk for Interactive Plot
            
                ```{r eruptions}
                inputPanel(...)(
                    selectInput("n_breaks", label = "Number of bins, ...),
                    sliderInput("bw_adjust", ...)
                )

                rederPlot({
                   hist(faithful$eruptions,..,breaks= as.number(input$n_breaks),
                   dens <- density(faithful$eruptions,.., adjust = input$bw_adjust)
                })
               ```