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

Suppress package message argument #70

Closed
hadley opened this issue Jan 26, 2017 · 9 comments
Closed

Suppress package message argument #70

hadley opened this issue Jan 26, 2017 · 9 comments

Comments

@hadley
Copy link
Member

@hadley hadley commented Jan 26, 2017

Defaulting to true, since usually it's not germane to the problem

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jul 13, 2017

Does this require computing on the language, e.g., find and transform all library() calls?

In a similar vein, I tend to forget to load "magrittr" in my reprexes (because I have it in .Rprofile), it would be great if reprex could detect pipe usage and fix the code for me.

Loading

@hadley
Copy link
Member Author

@hadley hadley commented Jul 13, 2017

You could either either use a hack to bind a session-wide packageStartupMessage handler, or provide a shim for library()

Loading

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 13, 2017

A lower tech solution is to insert extra chunk headers before and after every run of library() calls. If I do that by hand, it already works with the current package:

Input:

#+ message = FALSE
library(tidyverse)
message("1 can you hear me now?")

#+ body
as_tibble(iris)
message("2 can you hear me now?")

Output:

library(tidyverse)
message("1 can you hear me now?")
as_tibble(iris)
#> # A tibble: 150 x 5
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <dbl>       <dbl>        <dbl>       <dbl>  <fctr>
#>  1          5.1         3.5          1.4         0.2  setosa
#>  2          4.9         3.0          1.4         0.2  setosa
#>  3          4.7         3.2          1.3         0.2  setosa
#>  4          4.6         3.1          1.5         0.2  setosa
#>  5          5.0         3.6          1.4         0.2  setosa
#>  6          5.4         3.9          1.7         0.4  setosa
#>  7          4.6         3.4          1.4         0.3  setosa
#>  8          5.0         3.4          1.5         0.2  setosa
#>  9          4.4         2.9          1.4         0.2  setosa
#> 10          4.9         3.1          1.5         0.1  setosa
#> # ... with 140 more rows
message("2 can you hear me now?")
#> 2 can you hear me now?

Loading

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jul 13, 2017

Maybe just add a library argument to reprex(), defaulting to some option? (This package is mostly for interactive use, an option seems okay to me.)

Loading

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 13, 2017

it would be great if reprex could detect pipe usage and fix the code for me.

What fix do you have in mind here? Maybe insert

`%>%` <- magrittr::`%>%`

whenever the pipe is found in the source? But so many packages re-export it and this wouldn't be necessary. Or do you mean deploy the fix iff the reprex fails?

Loading

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jul 13, 2017

Yes, or library(magrittr). But I don't want to overthink this.

I'd find it easier to write reprex(library = "magrittr") for some one-liner I've copied to the clipboard, than starting a new text file and typing the library() call myself, then copying the contents and then calling reprex().

Loading

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jul 28, 2017

Maybe surround the whole knit() call with suppressPackageStartupMessages() (or an equivalent?)

Loading

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 31, 2017

To what extent are we trying to suppress the tidyverse startup message vs startup messages in general? Because if it's focused on the tidyverse, we just toggle this option in the template:

https://github.com/tidyverse/tidyverse/blame/c13baecbe13f9d99054f424da1bc39952ceca360/NEWS.md#L3-L4

Loading

jennybc added a commit that referenced this issue Sep 17, 2017
* Take control of tidyverse startup message; special case of #70

* Properly declare need for dev version of testthat

* NEWS bullet
@jennybc
Copy link
Member

@jennybc jennybc commented Sep 22, 2017

I have solved the specific problem of suppressing the tidy verse startup message. I'm going to close this and see if we truly feel the need for more general mechanism.

Opened a separate issue re: the pipe: #106.

Loading

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

Successfully merging a pull request may close this issue.

None yet
3 participants