How can I suppress the output of a function? In this case, the output i want to suppress is a plot that is automatically produced, even when i assign the function call to an object. For example, if I run:
require(sensemakr)
estimate <- 0.091321
est_se <- 0.008321
dof <- 10000
sense_df <- sensemakr::ovb_contour_plot(estimate = estimate,
se = est_se,
dof = dof)
I get the values I want in sense_df
but it also prints the below plot
This is suboptimal as all the code is part of a markdown file and i'm using the results in sense_df
to make my own plot in the next chunk. So the automatic printing of this plot is just a bad example of what I go on to make.
I've tried following the advice in this post to use capture.output
, invisible
, or sink
but none seem to work.
EDIT 1:
The function is even overriding {r, fig.show = "hide"}
at the beginning of my chunk.
EDIT 2:
I have also attempted to follow the suggestion in this post. Wrapping the function call in dev.off
returns the error 'list' object cannot be coerced to type 'double'
, and wrapping it in pdf(file = NULL)
does prevent the plot from showing up but there is still a plot-sized print in the output, just no actual plot within it. E.g.