Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions that print output should have an option for suppressing it #158

Open
briandk opened this issue Oct 25, 2014 · 1 comment
Open

Comments

@briandk
Copy link
Owner

briandk commented Oct 25, 2014

granovagg.1w, granovagg.ds, and granovagg.cont all print tabular output after being called. And they kind of force it.

That forcing sucks when working with RMarkdown, because within code chunks you'll get output (designed for interactive R sessions, not publication) that still forcibly prints:

tuftetest_pdf__page_1_of_6_

All of the output offset by ## is the forced printed output. And, yes, it's possible to suppress that output in an RMarkdown code chunk using suppression options, particularly results='hide':

```{r, message=FALSE, warning=FALSE, results='hide'}

My preferred solution

We add a parameter (hooray!) or two to each function that allows the following:

  • Choosing to print or not print tabular output. This option should default to TRUE, so existing users don't see any difference.
  • If tabular output, getting to choose current plain-text output or formatted xtable output. And, this option should default to plain, again so existing users don't see any difference.

The idea is that if you're using an RMarkdown document, you know what you're doing, and you'd request (if required) xtable-formatted output, or none at all.

On the development side, what we'll need to do, I think, is add guard checks to the functions that print:

 if (print.table == TRUE && tabular.output.style == 'plain') {

which, in the case of granovagg.1w might look like

  PrintLinearModelSummary <- function(owp) {
    if (print.table == TRUE && tabular.output.style == 'plain') {
      if (length(levels(owp$data$group)) == 2) {
        PrintTtest(owp$data[, c("score", "group")])
      } 

      else {
        message("\nBelow is a linear model summary of your input data")
        print(owp$model.summary)
      }
    }
  }
@briandk
Copy link
Owner Author

briandk commented Oct 25, 2014

Note also that if we continue to use message() in many of the print functions means folks will still have to manually hide messages in r code chunks, using the message=FALSE option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant