How to generate report in pdf format using R

前端 未结 1 347
走了就别回头了
走了就别回头了 2021-01-28 21:53

I am trying to find out the R code which will give me the output of the statistical analysis(i.e. Regression, DOE, Gage RR) in pdf or html format by using R ( Not by using R-stu

相关标签:
1条回答
  • 2021-01-28 22:30

    Yes, RMarkdown/knitr is the way to go.

    See here for the documentation for creating a pdf document.

    Your Rmd file might look something like the following:

    ---
    title: "Report"
    author: "XXX"
    date: "January 7, 2017"
    output: pdf_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    ## Output
    
    ```{r}
    x <- rnorm(100, 40, 3)
    x
    
    y <- rnorm(100, 100, 5)
    y
    
    fit <- lm(y ~ x)
    summary(fit)
    ```
    
    ## Plot
    
    ```{r plot, echo=FALSE}
    plot(y)
    ```
    

    For an html document, simply change to output: html_document.

    Render the pdf or html document with rmarkdown::render('filepath/yourfile.Rmd')

    0 讨论(0)
提交回复
热议问题