问题
Will it be possible to suppress messages such as "Using date format..." when using a function like?
> ymd(vec)
Using date format %Y%m%d
Whilst these are good to see when you are casting a vector, it can be annoying in some circumstances.
回答1:
Looking at the ymd
code, it callse parse_date
, which gives those annoying messages via the command message
.
Looking at ?message
, there is a corresponding suppressMessages
:
suppressMessages(ymd(x))
(Note - other similar functions are suppressWarnings
, suppressPackageStartupMessages
, and capture.output
, all of which I have had to use in the past to stop unexpected bits of text turning up (I was outputting some bits to an HTML file and these didn't want these to be in it)).
回答2:
Manny, suppressMessages() is the only way to go at the moment. But I like your idea of an argument. I've put it on the todo list for lubridate. You could also use strptime() once you have the format for a vector of date-times.
来源:https://stackoverflow.com/questions/9168684/lubridate-messages