QBoard » Artificial Intelligence & ML » AI and ML - R » R - Markdown avoiding package loading messages

R - Markdown avoiding package loading messages

  • I have been using Knitr via R-Studio, and think it is pretty neat. I have a minor issue though. When I source a file in an R-Chunk, the knitr output includes external comments as follows:

    + FALSE Loading required package: ggplot2
    + FALSE Loading required package: gridExtra
    + FALSE Loading required package: grid
    + FALSE Loading required package: VGAM
    + FALSE Loading required package: splines
    + FALSE Loading required package: stats4
    + FALSE Attaching package: 'VGAM'
    + FALSE The following object(s) are masked from 'package:stats4':

     

    I have tried to set R-chunk options in various ways but still didn't seem to avoid the problem:

    ```{r echo=FALSE, cache=FALSE, results=FALSE, warning=FALSE, comment=FALSE, warning=FALSE} 
    source("C:/Rscripts/source.R");
    
    ```

     

    Is there any way to comment out these messages?

     
      December 22, 2021 1:46 PM IST
    0
  • My best solution on R Markdown was to create a code chunk only to load libraries and exclude everything in the chunk.

    {r results='asis', echo=FALSE, include=FALSE,}
    knitr::opts_chunk$set(echo = TRUE, warning=FALSE)
    #formating tables
    library(xtable)
    
    #data wrangling
    library(dplyr)
    
    #text processing
    library(stringi)
      December 30, 2021 1:00 PM IST
    0
  • ```{r results='hide', message=FALSE, warning=FALSE}
    library(RJSONIO)
    library(AnotherPackage)
    ```
      January 1, 2022 2:00 PM IST
    0