Can't suppress message from predict in markdown

Running RStudio 2022.07.1+554 "Spotted Wakerobin" Release (7872775ebddc40635780ca1ed238934c3345c5de, 2022-07-22) for Ubuntu Bionic
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

I cannot suppress a message from the predict command, which is quite irritating. It always wants to tell me what sort of interpolation it is doing.

Here is my reprex:


df_temp <- as_tibble(replicate(3,sample(0:100,10,rep=TRUE))) %>% rename(x=1, y=2, z=3)
df_temp <- sf::st_as_sf(df_temp, coords=c("x", "y"), agr = "identity")
df_out <- sf::st_sfc(sf::st_point(c(50,50))) 

fit_IDW <- gstat::gstat( 
  formula = z ~ 1,
  data = df_temp, 
  set = list(idp = 1) 
)

interp_IDW <- predict(fit_IDW, df_out)
suppressMessages(interp_IDW <- predict(fit_IDW, df_out))

[inverse distance weighted interpolation]
[inverse distance weighted interpolation]

you have chunk option like message = FALSE or warning = FALSE

But it all depends how the predict function is outputing this message. If they use cat() for example, then it will be harder - capture.output() should be helpful here.

But in that case, they should use message instead. Can you look into gstat code, or report to them that using suppressMessages or message = FALSE is not working ?

Reported on gstat git site, edzer recommended setting debug.level = 0, which mostly worked.

For gstat.cv additionally the option verbose=FALSE needs to be set.

1 Like

It sounds like a good solution !

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.