How to suppress warning messages from cast ()

I use cast() from the reshape package quite often. Almost every time this warning appears:

Aggregation requires fun.aggregate: length used as default

I tried to set options( warn =-1) , but to no avail. How can these warnings be suppressed?

+6
source share
2 answers

You can manually specify fun.aggregate as the length.

 cast(your_inputs_to_cast, fun.aggregate = length) 
+11
source

Aggregation requires fun.aggregate: length used as default

is message not a warning - letting you know that the function somehow decided for you. I think the best option is to answer @Dason, that is, manually specify this option.

However, if you do not want to do this:

You can suppress messages by wrapping a function in suppressMessages

Using an example from cast

 names(ChickWeight) <- tolower(names(ChickWeight)) chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE) suppressMessages(cast(chick_m, time ~ variable)) 

Or you can create your own function

 cast_suppress <- function(...){suppressMessages(cast(...))} cast_suppress(chick_m, time ~ variable) 
+11
source

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


All Articles