Skip to content

knit_print.data.frame shoud not pass ... to print() #2047

Closed

Description

@cderv

This is the result of an investigation with @DavisVaughan following a CRAN check error with tibbletime https://cran.r-project.org/web/checks/check_results_tibbletime.html and 12 more packages

CRAN email is :

CRAN packages with unused arguments error
That is
     DriveML SmartEDA anomalize bayestestR broom effectsize heemod
     isoreader mlrCPO panelr parameters tibbletime
These show very similar errors in vignette re-building on Solaris and
macOS (which do not have pandoc so test your package without): you may
wish to discuss this with the knitr maintainer.

We manage to reproduce the error using

library(rmarkdown)
knitr::opts_chunk$set(error = FALSE)
knitr::knit("vignettes/TT-01-time-based-filtering.Rmd")

which has this traceback

traceback
> traceback()
21: print.tbl_time(x, ...)
20: print(x, ...)
19: knit_print.data.frame(x, ...)
18: knit_print(x, ...)
17: withVisible(knit_print(x, ...))
16: fun(x, options = options)
15: value_fun(ev$value, ev$visible)
14: withVisible(value_fun(ev$value, ev$visible))
13: withCallingHandlers(withVisible(value_fun(ev$value, ev$visible)), 
        warning = wHandler, error = eHandler, message = mHandler)
12: handle(pv <- withCallingHandlers(withVisible(value_fun(ev$value, 
        ev$visible)), warning = wHandler, error = eHandler, message = mHandler))
11: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
        debug = debug, last = i == length(out), use_try = stop_on_error != 
            2L, keep_warning = keep_warning, keep_message = keep_message, 
        output_handler = output_handler, include_timing = include_timing)
10: evaluate::evaluate(...)
9: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), 
       keep_message = !isFALSE(options$message), stop_on_error = if (options$error && 
           options$include) 0L else 2L, output_handler = knit_handlers(options$render, 
           options))
8: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, 
       keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), 
       stop_on_error = if (options$error && options$include) 0L else 2L, 
       output_handler = knit_handlers(options$render, options)))
7: block_exec(params)
6: call_block(x)
5: process_group.block(group)
4: process_group(group)
3: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
       error = function(e) {
           setwd(wd)
           cat(res, sep = "\n", file = output %n% "")
           message("Quitting from lines ", paste(current_lines(i), 
               collapse = "-"), " (", knit_concord$get("infile"), 
               ") ")
       })
2: process_file(text, output)
1: knitr::knit("vignettes/TT-01-time-based-filtering.Rmd")

Without loading rmarkdown first, there is no error.

We believe this happens because rmarkdown:::knit_print.data.frame is called and pass ... to print()

knit_print.data.frame <- function(x, ...) {
context <- render_context()
# printing of certain expressions producing
# 'data.table' objects should be suppressed
printable <- TRUE
if ("data.table" %in% loadedNamespaces() &&
exists("shouldPrint", envir = asNamespace("data.table")))
{
shouldPrint <- get("shouldPrint", envir = asNamespace("data.table"))
printable <- tryCatch(
shouldPrint(x) || !inherits(x, "data.table"),
error = function(e) TRUE
)
}
if (!printable)
return(invisible(NULL))
if (!is.null(context$df_print)) {
if (identical(context$df_print, knitr::kable)) {
res <- c('', knitr::kable(x), '')
if (knitr::is_html_output())
res <- c('<div class="kable-table">', res, '</div>')
knitr::asis_output(one_string(res))
} else {
context$df_print(x)
}
} else {
print(x, ...)
}
}

These ... contains knit_print arguments inline and options
This will then trigger print.tbl_time passing those two arguments that throws the unused arguments error.

This error was hidden for now because it only happens if rmarkdown is loaded and we think it is now because of yihui/knitr@fb2f427#diff-d0d9f9e52333dc5483c4882b0923ed3e0d31de7534bb8601d3b992998698abc5

  • Before pandoc-citeproc was check, and was not there so FALSE was return with rmarkdown::pandoc_available being called. Now knitr::pandoc_available will load rmarkdown and the method will be registered.

One fix would be to not pass ... to print from knit_print so that inline and options are not passed to unknown print method that don't know about these arguments.

Unless I missed something and this is expected.

@yihui pinging you as this cause some CRAN check failure for others packages.

Activity

  1. DavisVaughan commented on Feb 16, 2021

    @DavisVaughan

    I took a quick look at a few of the failing CRAN packages to see where we were passing the ... down to. Most of the cases passed the ... down to a function that eventually didn't have ..., and options wasn't one of the named arguments that it did have, so the error was thrown.

    # both pass on to `tibble::trunc_mat` which doesn't have dots
    tibbletime:::print.tbl_time
    panelr:::print.panel_data
    
    # passes on to parameters:::.print_parameters_cfa_efa
    # which passes on to insight:::export_table
    # which doesn't have `...`
    parameters:::print.parameters_efa
    
    # also passes on to `insight:::export_table`
    effectsize:::print.effectsize_table
    
    # passes to internal print_data_frame(), which does not have `...`
    # https://github.com/easystats/bayestestR/blob/ca9a5d185ffc6fa4eaa01578949f547ef5c284e6/R/print.describe_posterior.R#L4
    # https://github.com/easystats/bayestestR/blob/ec957519148e0c53690037bc1cd3bc9847cce8ab/R/utils_print_data_frame.R#L1
    bayestestR:::print.describe_posterior
    

    Maybe it is the responsibility of tibbletime:::print.tbl_time() to capture the ... and only pass down the dots that correspond to named arguments in tibble::trunc_mat(). That would be one way to fix this.

    However, I do agree that print() when called from the data frame method of knit_print() should probably not be getting the options and inline arguments. Fixing that would probably immediately fix all of the failing packages, and feels like the right thing to do. After that the individual package authors can make their print methods more robust to this.

  2. cderv commented on Feb 16, 2021

    @cderv
    CollaboratorAuthor

    BTW, it does not error when using rmarkdown::render because html_document sets context$df_print which default to print but in this case, the ... are not passed, hence no error in the other packages.

    context$df_print(x)

    So this make the case to not pass ... to print - it does not seem to be required.

  3. added
    bug
    on Feb 16, 2021
  4. cderv commented on Feb 18, 2021

    @cderv
    CollaboratorAuthor

    For more context, the packages that could be impacted by this issue and have CRAN check failure based on the emails received are

    DriveML SmartEDA anomalize bayestestR broom effectsize heemod isoreader mlrCPO panelr parameters tibbletime
    

    It seems there are 2 false positives but the others have indeed the same errors related to :

    • Vignette failed on Solaris which as no pandoc ("Error: processing vignette")
    • The error is with options = being passed and unused ("unused argument (options")
    pkgs <- c("DriveML","SmartEDA","anomalize","bayestestR", "broom", "effectsize",  "heemod",
              "isoreader", "mlrCPO", "panelr", "parameters", "tibbletime")
    
    checks <- purrr::map(pkgs, ~ {
                 rcmdcheck::cran_check_results(.x, flavours = "r-patched-solaris-x86")
    })
    
    xfun::raw_string(checks[[1]][[1]]$warnings)
    #> checking re-building of vignette outputs ... [8s/13s] WARNING
    #> Error(s) in re-building vignettes:
    #>   ...
    #> --- re-building ‘SmartML.Rmd’ using rmarkdown
    #> Warning in engine$weave(file, quiet = quiet, encoding = enc) :
    #>   Pandoc (>= 1.12.3) and/or pandoc-citeproc not available. Falling back to R Markdown v1.
    #> Quitting from lines 169-170 (SmartML.Rmd) 
    #> Error: processing vignette 'SmartML.Rmd' failed with diagnostics:
    #> unused argument (options = list(TRUE, FALSE, "markup", FALSE, NULL, FALSE, FALSE, "##", TRUE, TRUE, "normalsize", "#F7F7F7", 0, "cache/", NULL, TRUE, NULL, FALSE, FALSE, "high", "asis", "default", "figure/", "png", NULL, 72, "png", 7, 7, "figure", NULL, NULL, "fig:", NULL, "", NULL, NULL, NULL, 1, TRUE, FALSE, 1, "controls,loop", FALSE, FALSE, TRUE, list(c("age", "age", "age", "chol", "chol", "chol", "oldpeak", "oldpeak", "oldpeak", "thalach", "thalach", "thalach", "trestbps", "trestbps", "trestbps"), c("target_var:All", 
    #> "target_var:1", "target_var:0", "target_var:All", "target_var:1", "target_var:0", "target_var:All", "target_var:1", "target_var:0", "target_var:All", "target_var:1", "target_var:0", "target_var:All", "target_var:1", "target_var:0"), c(303, 165, 138, 303, 165, 138, 303, 165, 138, 303, 165, 138, 303, 165, 138), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 99, 74, 25, 0, 0, 0, 0, 0, 0), c(303, 165, 138, 303, 165, 138, 204, 91, 113, 303, 165, 138, 303, 165, 138), c(0, 0, 0, 0, 
    #> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), c(16473, 8662, 7811, 74618, 39968, 34650, 315, 96.2, 218.8, 45343, 26147, 19196, 39882, 21335, 18547), c(29, 29, 35, 126, 126, 131, 0, 0, 0, 71, 96, 71, 94, 94, 100), c(77, 76, 77, 564, 564, 409, 6.2, 4.2, 6.2, 202, 202, 195, 200, 180, 200), c(54.37, 52.5, 56.6, 246.26, 242.23, 251.09, 1.04, 0.58, 1.59, 149.65, 158.47, 139.1, 
    #> 131.62, 129.3, 134.4), c(55, 52, 58, 240, 234, 249, 0.8, 0.2, 1.4, 153, 161, 142, 130, 130, 130), c(9.08, 9.55, 7.96, 51.83, 53.55, 49.45, 1.16, 0.78, 1.3, 22.91, 19.17, 22.6, 17.54, 16.17, 18.73), c(0.17, 0.18, 0.14, 0.21, 0.22, 0.2, 1.12, 1.34, 0.82, 0.15, 0.12, 0.16, 0.13, 0.13, 0.14), c(13.5, 15, 10, 63.5, 59, 65.75, 1.6, 1, 1.9, 32.5, 23, 31, 20, 20, 24.75), c(-0.2, 0.12, -0.54, 1.14, 1.73, 0.31, 1.26, 1.63, 0.73, -0.53, -0.7, -0.29, 0.71, 0.42, 0.85), c(-0.55, -0.63, 0.08, 4.41, 7.37, 0.32, 
    #> 1.53, 3.06, 0.35, -0.08, 0.41, -0.23, 0.89, 0.35, 0.84), c(29, 29, 35, 126, 126, 131, 0, 0, 0, 71, 96, 71, 94, 94, 100), c(42, 41, 44.7, 188, 192, 187.7, 0, 0, 0, 116, 131, 108.7, 110, 110, 110), c(45, 43, 50, 204, 202.6, 206.4, 0, 0, 0.14, 130, 144, 120, 120, 118, 120), c(50, 46, 54, 217.6, 212.2, 225.3, 0, 0, 0.8, 140.6, 152, 127.1, 120, 120, 124), c(53, 50.6, 56.8, 230, 223, 235.6, 0.38, 0, 1, 146, 157, 132.8, 126, 125, 128), c(55, 52, 58, 240, 234, 249, 0.8, 0.2, 1.4, 153, 161, 142, 130, 130, 
    #> 130), c(58, 54, 59, 254, 245, 261.4, 1.12, 0.5, 1.8, 159, 164.4, 145.2, 134, 130, 138), c(59, 57.8, 61, 268, 260.8, 275.9, 1.4, 0.8, 2.19, 163, 170, 152.9, 140, 138, 140), c(62, 62, 63, 285.2, 273.4, 289, 1.9, 1.2, 2.8, 170, 173.2, 160, 144, 140, 150), c(66, 65.6, 66, 308.8, 305.2, 312.2, 2.8, 1.6, 3.4, 176.6, 179.6, 166.6, 152, 150, 160), c(77, 76, 77, 564, 564, 409, 6.2, 4.2, 6.2, 202, 202, 195, 200, 180, 200), c(27.25, 21.5, 37, 115.75, 119.5, 118.62, -2.4, -1.5, -2.25, 84.75, 114.5, 78.5, 90, 
    #> 90, 82.88), c(81.25, 81.5, 77, 369.75, 355.5, 381.62, 4, 2.5, 5.35, 214.75, 206.5, 202.5, 170, 170, 181.88), c(0, 0, 2, 5, 4, 2, 5, 4, 2, 1, 4, 1, 9, 3, 2)), NULL, NULL, "R", FALSE, TRUE, TRUE, "snc3", "paged_table(snc)", 504, 504, "snc3,warning=FALSE,eval=T,render=snc,echo=F"))
    #> --- failed re-building ‘SmartML.Rmd’
    #> 
    #> SUMMARY: processing the following file failed:
    #>   ‘SmartML.Rmd’
    #> 
    #> Error: Vignette re-building failed.
    #> Execution halted
    
    # the error is the same 
    purrr::map_dfr(checks, ~{
      res <- .x[[1]]
      data.frame(
        pkg = res$package,
        unused_argument = grepl("unused argument \\(options", res$warnings) && 
          grepl("Error: processing vignette", res$warnings)
      )
    })
    #>           pkg unused_argument
    #> 1     DriveML            TRUE
    #> 2    SmartEDA            TRUE
    #> 3   anomalize            TRUE
    #> 4  bayestestR            TRUE
    #> 5       broom              NA
    #> 6  effectsize            TRUE
    #> 7      heemod            TRUE
    #> 8   isoreader              NA
    #> 9      mlrCPO            TRUE
    #> 10     panelr            TRUE
    #> 11 parameters            TRUE
    #> 12 tibbletime            TRUE

    Created on 2021-02-18 by the reprex package (v1.0.0)

  5. added a commit that references this issue on Feb 18, 2021
  6. DavisVaughan commented on Feb 18, 2021

    @DavisVaughan
  7. cderv commented on Feb 19, 2021

    @cderv
    CollaboratorAuthor

    Oh yes I forgot you mentioned that. It is indeed:

    pkgs <- c("broom.helpers")
    
    checks <- purrr::map(pkgs, ~ {
      rcmdcheck::cran_check_results(.x, flavours = "r-patched-solaris-x86")
    })
    
    purrr::map_dfr(checks, ~{
      res <- .x[[1]]
      data.frame(
        pkg = res$package,
        unused_argument = grepl("unused argument \\(options", res$warnings) && 
          grepl("Error: processing vignette", res$warnings)
      )
    })
    #>             pkg unused_argument
    #> 1 broom.helpers            TRUE

    Created on 2021-02-19 by the reprex package (v1.0.0)

    The email was sent to them too. Thanks!

  8. cderv commented on Feb 23, 2021

    @cderv
    CollaboratorAuthor

    There are still issues on macOS but it is mainly because the 2.7 binary is not yet build

    pkgs <- c("DriveML","SmartEDA","anomalize","bayestestR", "broom.helpers", "effectsize",  "heemod",
              "isoreader", "mlrCPO", "panelr", "parameters", "tibbletime")
    
    checks <- purrr::map(pkgs, ~ {
      rcmdcheck::cran_check_results(.x)
    })
    
    failures <- purrr::map_dfr(checks, ~ {
      pkg <- .x
      purrr::imap_dfr(pkg, ~ {
        data.frame(
          pkg = .x$package,
          flavor = .y,
          unused_argument = grepl("unused argument \\(options", .x$warnings) && 
            grepl("Error: processing vignette", .x$warnings)
        )
      })
    })
    
    library(dplyr)
    #> 
    #> Attachement du package : 'dplyr'
    #> The following objects are masked from 'package:stats':
    #> 
    #>     filter, lag
    #> The following objects are masked from 'package:base':
    #> 
    #>     intersect, setdiff, setequal, union
    failures %>%
      filter(unused_argument)
    #>             pkg                 flavor unused_argument
    #> 1       DriveML r-release-macos-x86_64            TRUE
    #> 2       DriveML  r-oldrel-macos-x86_64            TRUE
    #> 3      SmartEDA r-release-macos-x86_64            TRUE
    #> 4      SmartEDA  r-oldrel-macos-x86_64            TRUE
    #> 5 broom.helpers r-release-macos-x86_64            TRUE
    #> 6 broom.helpers  r-oldrel-macos-x86_64            TRUE

    Created on 2021-02-23 by the reprex package (v1.0.0.9001)

  9. github-actions commented on Aug 24, 2021

    @github-actions

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

  10. locked as resolved and limited conversation to collaborators on Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions