11

ggpairs prints out a progress bar and estimated remaining time while generating plots, which is nice when used interactively since some of the computations can take a few seconds. But when making documents, like R notebooks, these printed messages end up in the report. ggpairs had a boolean verbose option, but it's depricated now. Is there an alternative? I can't seem to find one.

To see the messages try:

library(GGally) ggpairs(mtcars, columns = c("mpg", "cyl", "hp", "disp", "am", "qsec"))

In a document it ends up including:

plot: [1,1] [==-------------------------------------------] 4% est: 0s

plot: [1,2] [====-----------------------------------------] 8% est: 6s

plot: [1,3] [=====----------------------------------------] 12% est: 5s

plot: [1,4] [=======--------------------------------------] 16% est: 5s

etc

6
  • can you use message = FALSE in the chunk options Jan 10, 2017 at 20:08
  • I tried message = FALSE, warnings = FALSE but they still show up.
    – adatum
    Jan 10, 2017 at 20:11
  • I also tried wrapping the code in suppressMessages(). Didn't work either.
    – adatum
    Jan 10, 2017 at 20:13
  • Try with progress = FALSE. It seems to be called by ggmatrix_gtable, which takes a boolean progress argument. I'm not sure (haven't tested) if progress = F will be passed along deep enough. Jan 10, 2017 at 20:34
  • @Gregor progress = FALSE in chunk option didn't work either.
    – adatum
    Jan 10, 2017 at 20:50

3 Answers 3

10

The progress = FALSE argument will work when printing the ggpairs plot.

ggp = ggpairs(mtcars, columns = c("mpg", "cyl", "hp", "disp"))
print(ggp, progress = F)  # no progress bar
print(ggp)  # progress bar

It may also depend how you knit. The function that call the progress bar is ggmatrix_gtable, with the default value as

 progress = interactive() && (pm$ncol * pm$nrow) > 15

Thus no progress bar is printed by default in a non-interactive session.

1
  • Thank, this works! Re: knitting, I'm using the recently added Preview Notebook button in RStudio.
    – adatum
    Jan 10, 2017 at 21:13
7

'progress' parameter in print function will soon be deprecated.

It can be passed to ggpairs itself:

library(GGally)
ggpairs(mtcars, 
        columns = c("mpg", "cyl", "hp", "disp", "am", "qsec"),
        progress = FALSE)

RStudio screenshot for ggpairs without progress:

ggpairs output without progress

4

If you are familiar with dplyr syntax, maybe the following piping is the most elegant one which do not require saving intermediate variable

mtcars %>% 
  ggpairs(columns = c("mpg", "cyl", "hp", "disp", "am", "qsec")) %>%
  print(progress = F)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.