EvaMaeRey / flipbookr

Presenting code step-by-step and side-by-side with its output
https://evamaerey.github.io/flipbookr/
Other
198 stars 20 forks source link

Add note about {gt} library? #36

Closed BenjaminWolfe closed 4 years ago

BenjaminWolfe commented 4 years ago

Hi @EvaMaeRey!!

Using your package for a tech talk at work! Quick note that the starter template needs the {gt} package but I didn't have that installed and I don't think I saw it mentioned in the readme instructions anywhere. Tweaking that could make the process a little smoother for the total beginner!

Quitting from lines 679-682 (tech-talk-20200921.Rmd) 
Error in library(gt) : there is no package called 'gt'
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> library

Maybe you could add it to the suggests for the package (along with {xaringan}), and in the readme offer

devtools::install_github("EvaMaeRey/flipbookr", dependencies = TRUE)

—because dependencies is then passed on in the ... to install which takes it from install.packages, where it says this:

[dependencies is a] logical indicating whether to also install uninstalled packages which these packages depend on/link to/import/suggest (and so on recursively). Not used if repos = NULL. Can also be a character vector, a subset of c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances").

...

The default, NA, means c("Depends", "Imports", "LinkingTo").

TRUE means to use c("Depends", "Imports", "LinkingTo", "Suggests")...

BenjaminWolfe commented 4 years ago

Other quick notes while I'm in here…

BenjaminWolfe commented 4 years ago

Lastly, the just_for_evamaerey chunks still resulted in errors for me, and I'm not 💯 sure why.

To make that even less likely, you could do something like this!

Add this to your initial chunk:

template_dir <- file.path("flipbookr", "inst", "rmarkdown", "templates")
is_template <- stringr::str_detect(knitr::current_input(dir = TRUE), template_dir)

And then instead of eval = T for the just_for_evamaerey chunk, you could use eval = is_template.

If you like these changes I could do a pull request, or a series of them one for each thing I brought up.

EvaMaeRey commented 4 years ago

Thanks for these! I hope to get to them soon! Have some ideas...

EvaMaeRey commented 4 years ago

made some adjustments... So far not doing anything with the just for me chunk, but might come back to it.

BenjaminWolfe commented 4 years ago

Ooh ooh but also if you did decide to keep this in the main branch, you could also wrap what I wrote above into a function:

is_template <- function() {
  template_dir <- file.path("flipbookr", "inst", "rmarkdown", "templates")
  stringr::str_detect(knitr::current_input(dir = TRUE), template_dir)
}

And you wouldn't even have to export it! And you could use eval=flipbookr:::is_template()!

Buuuuuuuut I guess I see how it might be better to use a development branch. :smile: