read_excel read in messages- Suppress?

主宰稳场 提交于 2019-12-07 18:08:39

问题


I love using the readxl package. However, I've been using it as part of an RMarkdown document and some of the read_excel() message when reading in files are useful when doing analysis but not when trying to present the analysis. So the question is, is there any way to suppress the message received (or any warning message for that matter) when using read_excel? I'll take an RMarkdown OR read_excel solution.

Here is an illustration of the type of message I'd like to suppress. The appears in my final Rmarkdown document:

## Parsed with column specification:
## cols(
##   .default = col_character(),
##   Year = col_integer(),
##   Month = col_integer(),
##   Date = col_date(format = ""),
##   Day = col_integer(),
##   Replicate = col_integer(),
##   Time = col_integer(),
##   Depth = col_double(),
##   DenTotal = col_integer()
## )
## See spec(...) for full column specifications.

I haven't been able to find a way to read in an excel file from a url using read_excel so I'm not able to make a reproducible example here.


回答1:


If the package prints out messages using the message function, then the suppressMessages should work to prevent the messages from printing. From the help file, ?suppressMessages,

evaluates its expression in a context that ignores all ‘simple’ diagnostic messages.



来源:https://stackoverflow.com/questions/41227867/read-excel-read-in-messages-suppress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!