问题
I'm melting some data and don't want to provide an id.var parameter to melt. The data melts fine, but I get the
"No id variables; using all as measure variables"
Is there a way to prevent that message from coming up, or a way to say id.var=default or something like that? An iris example using dplyr:
> dt <- iris %>% summarize_at(c("Sepal.Length","Sepal.Width"), funs(mean))
> dt
Sepal.Length Sepal.Width
1 5.843333 3.057333
> melt(dt, value.name="Mean")
No id variables; using all as measure variables
variable Mean
1 Sepal.Length 5.843333
2 Sepal.Width 3.057333
Alternatively is there a way to tell a function to not print warning messages or something like that? Thanks!
回答1:
Strictly speaking, this is a message, not a warning. (see ?message
and ?warning
). You can suppress messages with suppressMessages
suppressMessages({
reshape2::melt(head(mtcars))
})
For melt
specifically, you may use id.vars = NULL
. (with credit to @user20650)
来源:https://stackoverflow.com/questions/48774207/in-r-using-melt-how-can-i-hide-warning-messages