Skip to content

Pass functions to summary_row #921

@thebioengineer

Description

@thebioengineer

Prework

  • Read and agree to the code of conduct and contributing guidelines.
  • If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

Description

Describe the bug clearly and concisely.

The documentation of summary_row indicates the user should be able to provide a bare function to the fns argument (when its in a named list). Currently, you get "Error: All functions provided as bare names in fns need a label."

Reproducible example

  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.
library(gt)
library(tidyverse)

exibble %>%
  select(-c(fctr, date, time, datetime)) %>%
  gt(rowname_col = "row", groupname_col = "group") %>%
  fmt_missing(columns = everything()) %>% 
  summary_rows(
    groups = TRUE,
    columns = num,
    fns = list(
      average = mean,
      total = sum,
      SD = sd
    )
  )
#> Error: All functions provided as bare names in `fns` need a label.

Created on 2022-04-05 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.1.1 (2021-08-10)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Los_Angeles         
#>  date     2022-04-05                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.1)
#>  backports     1.2.1   2020-12-09 [1] CRAN (R 4.1.1)
#>  broom         0.7.9   2021-07-27 [1] CRAN (R 4.1.1)
#>  cellranger    1.1.0   2016-07-27 [1] CRAN (R 4.1.1)
#>  checkmate     2.0.0   2020-02-06 [1] CRAN (R 4.1.1)
#>  cli           3.0.1   2021-07-17 [1] CRAN (R 4.1.1)
#>  colorspace    2.0-2   2021-06-24 [1] CRAN (R 4.1.1)
#>  crayon        1.4.1   2021-02-08 [1] CRAN (R 4.1.1)
#>  DBI           1.1.1   2021-01-15 [1] CRAN (R 4.1.1)
#>  dbplyr        2.1.1   2021-04-06 [1] CRAN (R 4.1.1)
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.1.1)
#>  dplyr       * 1.0.7   2021-06-18 [1] CRAN (R 4.1.1)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.1)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.1)
#>  fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.1)
#>  forcats     * 0.5.1   2021-01-27 [1] CRAN (R 4.1.1)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.1.1)
#>  generics      0.1.0   2020-10-31 [1] CRAN (R 4.1.1)
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.1)
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.1.1)
#>  gt          * 0.3.1   2021-08-07 [1] CRAN (R 4.1.1)
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 4.1.1)
#>  haven         2.4.3   2021-08-04 [1] CRAN (R 4.1.1)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.1)
#>  hms           1.1.1   2021-09-26 [1] CRAN (R 4.1.1)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.1)
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.1.1)
#>  jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.1.1)
#>  knitr         1.36    2021-09-29 [1] CRAN (R 4.1.1)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.1)
#>  lubridate     1.7.10  2021-02-26 [1] CRAN (R 4.1.1)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.1.1)
#>  modelr        0.1.8   2020-05-19 [1] CRAN (R 4.1.1)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.1.1)
#>  pillar        1.6.3   2021-09-26 [1] CRAN (R 4.1.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.1)
#>  purrr       * 0.3.4   2020-04-17 [1] CRAN (R 4.1.1)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.2)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.1)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.1)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.2)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.1)
#>  Rcpp          1.0.7   2021-07-07 [1] CRAN (R 4.1.1)
#>  readr       * 2.0.2   2021-09-27 [1] CRAN (R 4.1.1)
#>  readxl        1.3.1   2019-03-13 [1] CRAN (R 4.1.1)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.3)
#>  rlang         0.4.11  2021-04-30 [1] CRAN (R 4.1.1)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.1)
#>  rvest         1.0.1   2021-07-26 [1] CRAN (R 4.1.1)
#>  scales        1.1.1   2020-05-11 [1] CRAN (R 4.1.1)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.1)
#>  stringi       1.7.4   2021-08-25 [1] CRAN (R 4.1.1)
#>  stringr     * 1.4.0   2019-02-10 [1] CRAN (R 4.1.1)
#>  styler        1.6.2   2021-09-23 [1] CRAN (R 4.1.1)
#>  tibble      * 3.1.4   2021-08-25 [1] CRAN (R 4.1.1)
#>  tidyr       * 1.1.4   2021-09-27 [1] CRAN (R 4.1.1)
#>  tidyselect    1.1.1   2021-04-30 [1] CRAN (R 4.1.1)
#>  tidyverse   * 1.3.1   2021-04-15 [1] CRAN (R 4.1.1)
#>  tzdb          0.1.2   2021-07-20 [1] CRAN (R 4.1.1)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.1)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.1)
#>  withr         2.4.2   2021-04-18 [1] CRAN (R 4.1.1)
#>  xfun          0.26    2021-09-14 [1] CRAN (R 4.1.1)
#>  xml2          1.3.2   2020-04-23 [1] CRAN (R 4.1.1)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.0)
#> 

Created on 2022-04-05 by the reprex package (v2.0.1)

Expected result

What should have happened? Please be as specific as possible.

I expect the the functions to be applied as written to the column "num", creating new summary rows with rownames average, total, and SD. Am I misreading the documentation?

Session info

End the reproducible example with a call to sessionInfo() in the same session (e.g. reprex(session_info = TRUE)) and include the output.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions