简体   繁体   中英

Suppress All Messages/Warnings with Readr read_csv function

I am creating a rmarkdown pdf report. I used read_csv function from readr package to import some csv files in a folder. I used SuppressMessages/Warnings functions to hide all warnings/messages, but I still get the messages as below when trying to import multiple files:

It seems SuppressMessages/Warnings don't work on the parsing warnings.

## Parsed with column specification:
## cols(
## .default = col_character(),
## `Constant USD - Accrued Sum` = col_number(),
## `Units Sold Sum` = col_number()
## )

Because the report is aimed for non-technical audience, the warning messages can be a distraction. What can I do to keep this message from showing?

Just add col_types = cols() in the read_csv() function call

read_csv("path/to/file", col_types = cols())

Add message=FALSE to the chunk header:

```{r message=FALSE}
library("readr")
test <- read_csv("example.csv")
```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM