From 98401669804be2874f40a9f116be2c48bbd1ecba Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Fri, 26 Jun 2020 11:42:20 -0400 Subject: [PATCH 1/9] split call_block into a function block_params to extract the params to get a data.frame of parameters if looped --- R/block.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/block.R b/R/block.R index 4cea8a5537..dd5dfc9811 100644 --- a/R/block.R +++ b/R/block.R @@ -11,7 +11,7 @@ process_group.inline = function(x) { } -call_block = function(block) { +block_params = function(block) { # now try eval all options except those in eval.after and their aliases af = opts_knit$get('eval.after'); al = opts_knit$get('aliases') if (!is.null(al) && !is.null(af)) af = c(af, names(al[af %in% al])) @@ -89,6 +89,12 @@ call_block = function(block) { op = options(params$R.options); on.exit(options(op), add = TRUE) } + return(params) +} + +call_block = function(block) { + params = block_params(block) + block_exec(params) } From 538cd65bd502a0da1fedca529bdedcf3c34c6d22 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Fri, 26 Jun 2020 12:04:52 -0400 Subject: [PATCH 2/9] added a verbosity argument that you can turn off --- R/block.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/block.R b/R/block.R index dd5dfc9811..e04baf356b 100644 --- a/R/block.R +++ b/R/block.R @@ -11,7 +11,7 @@ process_group.inline = function(x) { } -block_params = function(block) { +block_params = function(block, verbose = TRUE) { # now try eval all options except those in eval.after and their aliases af = opts_knit$get('eval.after'); al = opts_knit$get('aliases') if (!is.null(al) && !is.null(af)) af = c(af, names(al[af %in% al])) @@ -29,7 +29,7 @@ block_params = function(block) { label = ref.label = params$label if (!is.null(params$ref.label)) ref.label = sc_split(params$ref.label) params[["code"]] = params[["code"]] %n% unlist(knit_code$get(ref.label), use.names = FALSE) - if (opts_knit$get('progress')) print(block) + if (opts_knit$get('progress') && verbose > 0) print(block) if (!is.null(params$child)) { if (!is_blank(params$code)) warning( @@ -93,7 +93,7 @@ block_params = function(block) { } call_block = function(block) { - params = block_params(block) + params = block_params(block, verbose = TRUE) block_exec(params) } From 4d64cd044f48d15e85af709d3dfea7db4f02cc22 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Tue, 21 Jul 2020 11:31:17 -0400 Subject: [PATCH 3/9] false trigger to see if fixed knitr --- DESCRIPTION | 1 + inst/misc/tweak_bib.csv | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1cc6bd19bb..3d9cbdd6d4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -183,3 +183,4 @@ Collate: 'utils-vignettes.R' 'zzz.R' RoxygenNote: 7.1.0 + diff --git a/inst/misc/tweak_bib.csv b/inst/misc/tweak_bib.csv index 119f58884e..a167151df9 100644 --- a/inst/misc/tweak_bib.csv +++ b/inst/misc/tweak_bib.csv @@ -1,33 +1,28 @@ "package","author" -"BiplotGUI","Anthony la Grange and N. J. le Roux and P.J. Rousseeuw and I. Ruts and J. W. Tukey" -"CircStats","Ulric Lund and Claudio Agostinelli" -"ElemStatLearn","Kjetil Halvorsen" -"Fahrmeir","Kjetil Halvorsen" -"Hmisc","Harrell, Jr., Frank E" -"Hmisc","Frank E. {Harrell, Jr.}" -"R2SWF","Yixuan Qiu and Yihui Xie and Cameron Bracken" -"R2WinBUGS","Andrew Gelman and Sibylle Sturtz and Uwe Ligges and Gregor Gorjanc and Jouni Kerman" -"RODBC","Brian Ripley and Michael Lapsley" -"RgoogleMaps","Markus Loecher" -"Sleuth2","F. L. Ramsey and D. W. Schafer and Jeannie Sifneos and Berwin A. Turlach" "ade4","Stéphane Dray and Anne-Béatrice Dufour and Jean Thioulouse and Thibaut Jombart and Sandrine Pavoine and Jean R. Lobry and Sébastien Ollier and Aurélie Siberchicot and Daniel Chessel" "akima","H. Akima and Albrecht Gebhardt and Thomas Petzoldt and Martin Maechler" "ash","David W. Scott and Albrecht Gebhardt and Stephen Kaluzny" "bcpa","Jose Claudio Faria and Clarice Garcia Borges Demetrio" +"BiplotGUI","Anthony la Grange and N. J. le Roux and P.J. Rousseeuw and I. Ruts and J. W. Tukey" "bitops","Steve Dutky and Martin Maechler" "cacheSweave","Roger D. Peng" "cat","Ted Harding and Fernando Tusell and Joseph L. Schafer" +"CircStats","Ulric Lund and Claudio Agostinelli" "contrast","Max Kuhn and Steve Weston and Jed Wing and James Forester" "date","Terry Therneau and Thomas Lumley and Kjetil Halvorsen and Kurt Hornik" "digest","Dirk Eddelbuettel" +"ElemStatLearn","Kjetil Halvorsen" "epiR","Mark Stevenson and Telmo Nunes and Cord Heuer and Jonathon Marshall and Javier Sanchez and Ron Thornton and Jeno Reiczigel and Jim Robison-Cox and Paola Sebastiani and Peter Solymos" +"Fahrmeir","Kjetil Halvorsen" "flashClust","Fionn Murtagh and {R development team} and Peter Langfelder" "foreach","{Revolution Analytics} and Steve Weston}" "fortunes","Achim Zeileis and the R community" -"gWidgets","John Verzani" "gee","Vincent J Carey and Thomas Lumley and Brian Ripley" "gmodels","Gregory R. Warnes andBen Bolker and Thomas Lumley and Randall C Johnson and Randall C. Johnson" +"gWidgets","John Verzani" "hexbin","Dan Carr and Nicholas Lewin-Koh and Martin Maechler" +"Hmisc","Harrell, Jr., Frank E" +"Hmisc","Frank E. {Harrell, Jr.}" "leaps","Thomas Lumley" "mapproj","Doug McIlroy and Ray Brownrigg and Thomas P Minka and Roger Bivand" "maps","Ray Brownrigg" @@ -36,9 +31,14 @@ "pbivnorm","Alan Genz and Brenton Kenkel" "pscl","Simon Jackman and Alex Tahk and Achim Zeileis and Christina Maimone and Jim Fearon" "quadprog","Berwin A. Turlach and Andreas Weingessel" +"R2SWF","Yixuan Qiu and Yihui Xie and Cameron Bracken" +"R2WinBUGS","Andrew Gelman and Sibylle Sturtz and Uwe Ligges and Gregor Gorjanc and Jouni Kerman" "randomForest","Leo Breiman and Adele Cutler and Andy Liaw and Matthew Wiener" "rgl","Daniel Adler and Duncan Murdoch" +"RgoogleMaps","Markus Loecher" "rms","Frank E. {Harrell, Jr.}" "robustbase","Valentin Todorov and Andreas Ruckstuhl and Matias Salibian-Barrera and Tobias Verbeke and Manuel Koller and Martin Maechler" +"RODBC","Brian Ripley and Michael Lapsley" +"Sleuth2","F. L. Ramsey and D. W. Schafer and Jeannie Sifneos and Berwin A. Turlach" "sm","Adrian Bowman and Adelchi Azzalini" "tuneR","Uwe Ligges" From b9020f179ca49668a6d564e4fbd8c719975150bd Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Tue, 21 Jul 2020 12:02:18 -0400 Subject: [PATCH 4/9] removed to merge --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d9cbdd6d4..1cc6bd19bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -183,4 +183,3 @@ Collate: 'utils-vignettes.R' 'zzz.R' RoxygenNote: 7.1.0 - From 92f6e9761ca386a885752d09fc3df110b2c2ff50 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Thu, 23 Jul 2020 16:47:09 -0400 Subject: [PATCH 5/9] remove tweak --- inst/misc/tweak_bib.csv | 44 ----------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 inst/misc/tweak_bib.csv diff --git a/inst/misc/tweak_bib.csv b/inst/misc/tweak_bib.csv deleted file mode 100644 index a167151df9..0000000000 --- a/inst/misc/tweak_bib.csv +++ /dev/null @@ -1,44 +0,0 @@ -"package","author" -"ade4","Stéphane Dray and Anne-Béatrice Dufour and Jean Thioulouse and Thibaut Jombart and Sandrine Pavoine and Jean R. Lobry and Sébastien Ollier and Aurélie Siberchicot and Daniel Chessel" -"akima","H. Akima and Albrecht Gebhardt and Thomas Petzoldt and Martin Maechler" -"ash","David W. Scott and Albrecht Gebhardt and Stephen Kaluzny" -"bcpa","Jose Claudio Faria and Clarice Garcia Borges Demetrio" -"BiplotGUI","Anthony la Grange and N. J. le Roux and P.J. Rousseeuw and I. Ruts and J. W. Tukey" -"bitops","Steve Dutky and Martin Maechler" -"cacheSweave","Roger D. Peng" -"cat","Ted Harding and Fernando Tusell and Joseph L. Schafer" -"CircStats","Ulric Lund and Claudio Agostinelli" -"contrast","Max Kuhn and Steve Weston and Jed Wing and James Forester" -"date","Terry Therneau and Thomas Lumley and Kjetil Halvorsen and Kurt Hornik" -"digest","Dirk Eddelbuettel" -"ElemStatLearn","Kjetil Halvorsen" -"epiR","Mark Stevenson and Telmo Nunes and Cord Heuer and Jonathon Marshall and Javier Sanchez and Ron Thornton and Jeno Reiczigel and Jim Robison-Cox and Paola Sebastiani and Peter Solymos" -"Fahrmeir","Kjetil Halvorsen" -"flashClust","Fionn Murtagh and {R development team} and Peter Langfelder" -"foreach","{Revolution Analytics} and Steve Weston}" -"fortunes","Achim Zeileis and the R community" -"gee","Vincent J Carey and Thomas Lumley and Brian Ripley" -"gmodels","Gregory R. Warnes andBen Bolker and Thomas Lumley and Randall C Johnson and Randall C. Johnson" -"gWidgets","John Verzani" -"hexbin","Dan Carr and Nicholas Lewin-Koh and Martin Maechler" -"Hmisc","Harrell, Jr., Frank E" -"Hmisc","Frank E. {Harrell, Jr.}" -"leaps","Thomas Lumley" -"mapproj","Doug McIlroy and Ray Brownrigg and Thomas P Minka and Roger Bivand" -"maps","Ray Brownrigg" -"mathgraph","Patrick J. Burns and Nick Efthymiou and Claus Dethlefsen" -"oz","Bill Venables and Kurt Hornik" -"pbivnorm","Alan Genz and Brenton Kenkel" -"pscl","Simon Jackman and Alex Tahk and Achim Zeileis and Christina Maimone and Jim Fearon" -"quadprog","Berwin A. Turlach and Andreas Weingessel" -"R2SWF","Yixuan Qiu and Yihui Xie and Cameron Bracken" -"R2WinBUGS","Andrew Gelman and Sibylle Sturtz and Uwe Ligges and Gregor Gorjanc and Jouni Kerman" -"randomForest","Leo Breiman and Adele Cutler and Andy Liaw and Matthew Wiener" -"rgl","Daniel Adler and Duncan Murdoch" -"RgoogleMaps","Markus Loecher" -"rms","Frank E. {Harrell, Jr.}" -"robustbase","Valentin Todorov and Andreas Ruckstuhl and Matias Salibian-Barrera and Tobias Verbeke and Manuel Koller and Martin Maechler" -"RODBC","Brian Ripley and Michael Lapsley" -"Sleuth2","F. L. Ramsey and D. W. Schafer and Jeannie Sifneos and Berwin A. Turlach" -"sm","Adrian Bowman and Adelchi Azzalini" -"tuneR","Uwe Ligges" From ceb32efeaed523bd626f2644158184628d9001bf Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Thu, 23 Jul 2020 16:47:57 -0400 Subject: [PATCH 6/9] fixed tweak --- inst/misc/tweak_bib.csv | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 inst/misc/tweak_bib.csv diff --git a/inst/misc/tweak_bib.csv b/inst/misc/tweak_bib.csv new file mode 100644 index 0000000000..119f58884e --- /dev/null +++ b/inst/misc/tweak_bib.csv @@ -0,0 +1,44 @@ +"package","author" +"BiplotGUI","Anthony la Grange and N. J. le Roux and P.J. Rousseeuw and I. Ruts and J. W. Tukey" +"CircStats","Ulric Lund and Claudio Agostinelli" +"ElemStatLearn","Kjetil Halvorsen" +"Fahrmeir","Kjetil Halvorsen" +"Hmisc","Harrell, Jr., Frank E" +"Hmisc","Frank E. {Harrell, Jr.}" +"R2SWF","Yixuan Qiu and Yihui Xie and Cameron Bracken" +"R2WinBUGS","Andrew Gelman and Sibylle Sturtz and Uwe Ligges and Gregor Gorjanc and Jouni Kerman" +"RODBC","Brian Ripley and Michael Lapsley" +"RgoogleMaps","Markus Loecher" +"Sleuth2","F. L. Ramsey and D. W. Schafer and Jeannie Sifneos and Berwin A. Turlach" +"ade4","Stéphane Dray and Anne-Béatrice Dufour and Jean Thioulouse and Thibaut Jombart and Sandrine Pavoine and Jean R. Lobry and Sébastien Ollier and Aurélie Siberchicot and Daniel Chessel" +"akima","H. Akima and Albrecht Gebhardt and Thomas Petzoldt and Martin Maechler" +"ash","David W. Scott and Albrecht Gebhardt and Stephen Kaluzny" +"bcpa","Jose Claudio Faria and Clarice Garcia Borges Demetrio" +"bitops","Steve Dutky and Martin Maechler" +"cacheSweave","Roger D. Peng" +"cat","Ted Harding and Fernando Tusell and Joseph L. Schafer" +"contrast","Max Kuhn and Steve Weston and Jed Wing and James Forester" +"date","Terry Therneau and Thomas Lumley and Kjetil Halvorsen and Kurt Hornik" +"digest","Dirk Eddelbuettel" +"epiR","Mark Stevenson and Telmo Nunes and Cord Heuer and Jonathon Marshall and Javier Sanchez and Ron Thornton and Jeno Reiczigel and Jim Robison-Cox and Paola Sebastiani and Peter Solymos" +"flashClust","Fionn Murtagh and {R development team} and Peter Langfelder" +"foreach","{Revolution Analytics} and Steve Weston}" +"fortunes","Achim Zeileis and the R community" +"gWidgets","John Verzani" +"gee","Vincent J Carey and Thomas Lumley and Brian Ripley" +"gmodels","Gregory R. Warnes andBen Bolker and Thomas Lumley and Randall C Johnson and Randall C. Johnson" +"hexbin","Dan Carr and Nicholas Lewin-Koh and Martin Maechler" +"leaps","Thomas Lumley" +"mapproj","Doug McIlroy and Ray Brownrigg and Thomas P Minka and Roger Bivand" +"maps","Ray Brownrigg" +"mathgraph","Patrick J. Burns and Nick Efthymiou and Claus Dethlefsen" +"oz","Bill Venables and Kurt Hornik" +"pbivnorm","Alan Genz and Brenton Kenkel" +"pscl","Simon Jackman and Alex Tahk and Achim Zeileis and Christina Maimone and Jim Fearon" +"quadprog","Berwin A. Turlach and Andreas Weingessel" +"randomForest","Leo Breiman and Adele Cutler and Andy Liaw and Matthew Wiener" +"rgl","Daniel Adler and Duncan Murdoch" +"rms","Frank E. {Harrell, Jr.}" +"robustbase","Valentin Todorov and Andreas Ruckstuhl and Matias Salibian-Barrera and Tobias Verbeke and Manuel Koller and Martin Maechler" +"sm","Adrian Bowman and Adelchi Azzalini" +"tuneR","Uwe Ligges" From 55195ada2c7d546f967c08f5b2a1e66e0d78bde4 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Thu, 23 Jul 2020 17:41:52 -0400 Subject: [PATCH 7/9] reworked block so it gives params but still executes the same way --- R/block.R | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/R/block.R b/R/block.R index e04baf356b..d7276d302c 100644 --- a/R/block.R +++ b/R/block.R @@ -73,13 +73,29 @@ block_params = function(block, verbose = TRUE) { if (opts_knit$get('verbose')) message(' loading cache from ', hash) cache$load(hash, lazy = params$cache.lazy) cache_engine(params) + } + } else if (label %in% names(dep_list$get()) && !isFALSE(opts_knit$get('warn.uncached.dep'))) + warning2('code chunks must not depend on the uncached chunk "', label, '"') + + return(params) +} + +call_block = function(block) { + params = block_params(block, verbose = TRUE) + + # this is required here because return() in the if + # so that the params are returned in block_params, but + # the same logic execution is done below + if (params$cache > 0) { + if (cache$exists(params$hash, params$cache.lazy) && + isFALSE(params$cache.rebuild) && + params$engine != 'Rcpp') { if (!params$include) return('') - if (params$cache == 3) return(cache$output(hash)) + if (params$cache == 3) return(cache$output(params$hash)) } if (params$engine == 'R') cache$library(params$cache.path, save = FALSE) # load packages - } else if (label %in% names(dep_list$get()) && !isFALSE(opts_knit$get('warn.uncached.dep'))) - warning2('code chunks must not depend on the uncached chunk "', label, '"') + } # warning already triggered above params$params.src = block$params.src opts_current$restore(params) # save current options @@ -89,12 +105,6 @@ block_params = function(block, verbose = TRUE) { op = options(params$R.options); on.exit(options(op), add = TRUE) } - return(params) -} - -call_block = function(block) { - params = block_params(block, verbose = TRUE) - block_exec(params) } From 9b18fa3ebcf1569a929c66bb44e31df64c6e7f34 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Fri, 7 Aug 2020 15:53:45 -0400 Subject: [PATCH 8/9] passing through collapse argument --- R/block.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/block.R b/R/block.R index d7276d302c..f71715997d 100644 --- a/R/block.R +++ b/R/block.R @@ -80,7 +80,7 @@ block_params = function(block, verbose = TRUE) { return(params) } -call_block = function(block) { +call_block = function(block, collapse = '') { params = block_params(block, verbose = TRUE) # this is required here because return() in the if @@ -105,7 +105,7 @@ call_block = function(block) { op = options(params$R.options); on.exit(options(op), add = TRUE) } - block_exec(params) + block_exec(params, collapse = collapse) } # options that should affect cache when cache level = 1,2 @@ -115,7 +115,7 @@ cache2.opts = c('fig.keep', 'fig.path', 'fig.ext', 'dev', 'dpi', 'dev.args', 'fi # options that should not affect cache cache0.opts = c('include', 'out.width.px', 'out.height.px', 'cache.rebuild') -block_exec = function(options) { +block_exec = function(options, collapse = '') { # when code is not R language if (options$engine != 'R') { res.before = run_hooks(before = TRUE, options) @@ -123,7 +123,7 @@ block_exec = function(options) { output = in_dir(input_dir(), engine(options)) if (is.list(output)) output = unlist(output) res.after = run_hooks(before = FALSE, options) - output = paste(c(res.before, output, res.after), collapse = '') + output = paste(c(res.before, output, res.after), collapse = collapse) output = knit_hooks$get('chunk')(output, options) if (options$cache) { cache.exists = cache$exists(options$hash, options$cache.lazy) @@ -279,7 +279,7 @@ block_exec = function(options) { output = unlist(wrap(res, options)) # wrap all results together res.after = run_hooks(before = FALSE, options, env) # run 'after' hooks - output = paste(c(res.before, output, res.after), collapse = '') # insert hook results + output = paste(c(res.before, output, res.after), collapse = collapse) # insert hook results output = knit_hooks$get('chunk')(output, options) if (options$cache > 0) { From 0f890e2b49f8d08126669776c38ba0df2c0daec1 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Tue, 30 Mar 2021 09:17:26 -0400 Subject: [PATCH 9/9] whitespace removal --- man/knit_filter.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/knit_filter.Rd b/man/knit_filter.Rd index f8213ff0b0..9beec4409d 100644 --- a/man/knit_filter.Rd +++ b/man/knit_filter.Rd @@ -29,7 +29,7 @@ knitr_example = function(...) system.file("examples", ..., package = "knitr") if (Sys.which("aspell") != "") { # -t means the TeX mode utils::aspell(knitr_example("knitr-minimal.Rnw"), knit_filter, control = "-t") - + # -H is the HTML mode utils::aspell(knitr_example("knitr-minimal.Rmd"), knit_filter, control = "-H -t") }