Knitr shows comments from library import

I have a small Rnw file. When compiled with knitr, it shows the import of comments in pdf. How to remove these comments? Here is the a.Rnw file:

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
Hi, this is an example!
<<setup, echo=FALSE, cache=TRUE>>==
library(earth, warn.conflicts=FALSE)
a <- rnorm(100); b<- 0.05*rnorm(100) - .2*a
model <- lm(a~b)
plot(model)
@
\end{document}

When I compile with knitr

$ Rscript -e "library(knitr); knit('a.Rnw')"

I get this extraneous bit in the tex file:

\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
{\ttfamily\noindent\itshape\color{messagecolor}{\#\# Loading required package: plotmo\\\#\# Loading required package: plotrix}}\end{kframe} 

which is displayed as enter image description here

This is normal? How to remove these comments?

+4
source share
1 answer

The simplest thing is to put message=FALSEchunk in your parameters, locally for this fragment or through library(knitr); opts_chunk$set(message=FALSE)next to the title of your document.

, , @rawr , , cat() message() . message=FALSE , ;

suppressPackageStartupMessages(library(earth))

, , message=FALSE (, echo=TRUE).

+6

Source: https://habr.com/ru/post/1542528/


All Articles