├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── check-standard.yaml │ └── test-coverage.yaml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.md ├── R ├── filter.R ├── group_by.R ├── join.R ├── longer_wider.R ├── mutate.R ├── rename.R ├── select.R ├── summarize.R └── tidylog.R ├── README.Rmd ├── README.md ├── codecov.yml ├── cran-comments.md ├── generate_docs.R ├── man ├── add_count.Rd ├── add_tally.Rd ├── anti_join.Rd ├── count.Rd ├── distinct.Rd ├── distinct_all.Rd ├── distinct_at.Rd ├── distinct_if.Rd ├── drop_na.Rd ├── fill.Rd ├── filter.Rd ├── filter_all.Rd ├── filter_at.Rd ├── filter_if.Rd ├── full_join.Rd ├── gather.Rd ├── group_by.Rd ├── group_by_all.Rd ├── group_by_at.Rd ├── group_by_if.Rd ├── inner_join.Rd ├── left_join.Rd ├── mutate.Rd ├── mutate_all.Rd ├── mutate_at.Rd ├── mutate_if.Rd ├── pivot_longer.Rd ├── pivot_wider.Rd ├── relocate.Rd ├── rename.Rd ├── rename_all.Rd ├── rename_at.Rd ├── rename_if.Rd ├── rename_with.Rd ├── replace_na.Rd ├── right_join.Rd ├── sample_frac.Rd ├── sample_n.Rd ├── select.Rd ├── select_all.Rd ├── select_at.Rd ├── select_if.Rd ├── semi_join.Rd ├── separate_wider_delim.Rd ├── separate_wider_position.Rd ├── separate_wider_regex.Rd ├── slice.Rd ├── slice_head.Rd ├── slice_max.Rd ├── slice_min.Rd ├── slice_sample.Rd ├── slice_tail.Rd ├── spread.Rd ├── summarise.Rd ├── summarise_all.Rd ├── summarise_at.Rd ├── summarise_if.Rd ├── summarize.Rd ├── summarize_all.Rd ├── summarize_at.Rd ├── summarize_if.Rd ├── tally.Rd ├── tidylog.Rd ├── top_frac.Rd ├── top_n.Rd ├── transmute.Rd ├── transmute_all.Rd ├── transmute_at.Rd ├── transmute_if.Rd ├── uncount.Rd └── ungroup.Rd ├── tests ├── testthat.R └── testthat │ ├── test_filter.R │ ├── test_group_by.R │ ├── test_join.R │ ├── test_longer_wider.R │ ├── test_mutate.R │ ├── test_rename.R │ ├── test_select.R │ ├── test_summarize.R │ └── test_tidylog.R ├── tidylog.Rproj └── vignettes ├── .gitignore └── benchmarks.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^.*\.Rproj$ 3 | ^.*\.rhistory$ 4 | ^\.Rproj\.user$ 5 | ^data-raw$ 6 | ^README\.Rmd$ 7 | ^README-.*\.png$ 8 | ^cran-comments\.md$ 9 | ^codecov\.yml$ 10 | ^render_README\.R$ 11 | ^docs$ 12 | ^\.lintr$ 13 | ^log.txt$ 14 | ^generate_docs.R$ 15 | ^\.github$ 16 | ^CRAN-SUBMISSION$ 17 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/check-standard.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macos-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v3 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: any::rcmdcheck 45 | needs: check 46 | 47 | - uses: r-lib/actions/check-r-package@v2 48 | with: 49 | upload-snapshots: true 50 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - uses: r-lib/actions/setup-r-dependencies@v2 25 | with: 26 | extra-packages: any::covr 27 | needs: coverage 28 | 29 | - name: Test coverage 30 | run: | 31 | covr::codecov( 32 | quiet = FALSE, 33 | clean = FALSE, 34 | install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") 35 | ) 36 | shell: Rscript {0} 37 | 38 | - name: Show testthat output 39 | if: always() 40 | run: | 41 | ## -------------------------------------------------------------------- 42 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 43 | shell: bash 44 | 45 | - name: Upload test results 46 | if: failure() 47 | uses: actions/upload-artifact@v3 48 | with: 49 | name: coverage-test-failures 50 | path: ${{ runner.temp }}/package 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | data-raw/sc* 6 | log.txt 7 | CRAN-RELEASE 8 | .DS_Store 9 | inst/doc 10 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: tidylog 2 | Type: Package 3 | Title: Logging for 'dplyr' and 'tidyr' Functions 4 | Version: 1.1.0.9000 5 | Authors@R: c( 6 | person("Benjamin", "Elbers", email = "elbersb@gmail.com", 7 | role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5392-3448")), 8 | person("Damiano", "Oldoni", email = "damiano.oldoni@inbo.be", 9 | role = c("ctb"), comment = c(ORCID = "0000-0003-3445-7562")) 10 | ) 11 | Description: Provides feedback about 'dplyr' and 'tidyr' operations. 12 | License: MIT + file LICENSE 13 | Imports: dplyr, tidyr, glue, cli, rlang (>= 0.4.3) 14 | Suggests: 15 | testthat, 16 | units, 17 | nycflights13, 18 | covr, 19 | forcats, 20 | knitr, 21 | rmarkdown, 22 | bench 23 | Encoding: UTF-8 24 | URL: https://github.com/elbersb/tidylog/ 25 | BugReports: https://github.com/elbersb/tidylog/issues 26 | RoxygenNote: 7.3.1 27 | VignetteBuilder: knitr 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2018 2 | COPYRIGHT HOLDER: Benjamin Elbers 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(add_count) 4 | export(add_tally) 5 | export(anti_join) 6 | export(count) 7 | export(distinct) 8 | export(distinct_all) 9 | export(distinct_at) 10 | export(distinct_if) 11 | export(drop_na) 12 | export(fill) 13 | export(filter) 14 | export(filter_all) 15 | export(filter_at) 16 | export(filter_if) 17 | export(full_join) 18 | export(gather) 19 | export(group_by) 20 | export(group_by_all) 21 | export(group_by_at) 22 | export(group_by_if) 23 | export(inner_join) 24 | export(left_join) 25 | export(mutate) 26 | export(mutate_all) 27 | export(mutate_at) 28 | export(mutate_if) 29 | export(pivot_longer) 30 | export(pivot_wider) 31 | export(relocate) 32 | export(rename) 33 | export(rename_all) 34 | export(rename_at) 35 | export(rename_if) 36 | export(rename_with) 37 | export(replace_na) 38 | export(right_join) 39 | export(sample_frac) 40 | export(sample_n) 41 | export(select) 42 | export(select_all) 43 | export(select_at) 44 | export(select_if) 45 | export(semi_join) 46 | export(separate_wider_delim) 47 | export(separate_wider_position) 48 | export(separate_wider_regex) 49 | export(slice) 50 | export(slice_head) 51 | export(slice_max) 52 | export(slice_min) 53 | export(slice_sample) 54 | export(slice_tail) 55 | export(spread) 56 | export(summarise) 57 | export(summarise_all) 58 | export(summarise_at) 59 | export(summarise_if) 60 | export(summarize) 61 | export(summarize_all) 62 | export(summarize_at) 63 | export(summarize_if) 64 | export(tally) 65 | export(tidylog) 66 | export(top_frac) 67 | export(top_n) 68 | export(transmute) 69 | export(transmute_all) 70 | export(transmute_at) 71 | export(transmute_if) 72 | export(uncount) 73 | export(ungroup) 74 | import(dplyr) 75 | import(rlang) 76 | import(tidyr) 77 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # tidylog (development version) 2 | 3 | - use cli instead of clisymbols 4 | 5 | # 1.1.0 6 | 7 | - switch to Github Actions for CI 8 | - units package now supported (#51) 9 | - mutate: fix formatting issues for NAs (#48) 10 | - use rlang::inform instead of message (#41) 11 | - include dataset names in join messages (#46) 12 | - mutate now reports dropped columns (#53) 13 | - filter reports the number of groups (#52) 14 | - fix bug with new dplyr::join_by syntax (#58) 15 | - tidyr: support for separate_wider_* functions (#62) 16 | 17 | # 1.0.2 18 | 19 | - add a short benchmarking vignette 20 | - report type for new variables (#45) 21 | - add relocate, rename_with, slice_* from dplyr 1.0.0 22 | 23 | # 1.0.1 24 | 25 | - autogenerate documentation 26 | - data argument now has same name as in tidyr/dplyr (#43) 27 | - fixes #42 28 | - fixes "ungroup" bug in tests (found by revdep check for dplyr 1.0.0) 29 | 30 | # 1.0.0 31 | 32 | - tidyr: support for pivot_longer, pivot_wider 33 | - dplyr: support for ungroup (thanks @damianooldoni) 34 | - dplyr: support for rename_* (#27) 35 | - dplyr: support for top_frac, sample_n, sample_frac, slice 36 | - tidyr: support for uncount 37 | 38 | # 0.2.0 39 | - added detailed merge information for joins (#25) 40 | - added support for tidyr functions: gather, spread (thanks @WilDoane), drop_na (@jackhannah95), fill and replace_na 41 | - use clisymbols for ellipsis 42 | - add number of remaining rows to filter (#23) 43 | - bugfix: do not report negative NA (#18) 44 | - bugfix: avoid partial matching (closes #26) 45 | 46 | # 0.1.0 47 | 48 | initial release 49 | -------------------------------------------------------------------------------- /R/filter.R: -------------------------------------------------------------------------------- 1 | #' @import dplyr 2 | #' @import tidyr 3 | #' @export 4 | filter <- function(.data, ...) { 5 | log_filter(.data, .fun = dplyr::filter, .funname = "filter", ...) 6 | } 7 | 8 | #' @export 9 | filter_all <- function(.tbl, ...) { 10 | log_filter(.tbl, .fun = dplyr::filter_all, .funname = "filter_all", ...) 11 | } 12 | 13 | #' @export 14 | filter_if <- function(.tbl, ...) { 15 | log_filter(.tbl, .fun = dplyr::filter_if, .funname = "filter_if", ...) 16 | } 17 | 18 | #' @export 19 | filter_at <- function(.tbl, ...) { 20 | log_filter(.tbl, .fun = dplyr::filter_at, .funname = "filter_at", ...) 21 | } 22 | 23 | #' @export 24 | distinct <- function(.data, ...) { 25 | log_filter(.data, .fun = dplyr::distinct, .funname = "distinct", ...) 26 | } 27 | 28 | #' @export 29 | distinct_all <- function(.tbl, ...) { 30 | log_filter(.tbl, .fun = dplyr::distinct_all, .funname = "distinct_all", ...) 31 | } 32 | 33 | #' @export 34 | distinct_if <- function(.tbl, ...) { 35 | log_filter(.tbl, .fun = dplyr::distinct_if, .funname = "distinct_if", ...) 36 | } 37 | 38 | #' @export 39 | distinct_at <- function(.tbl, ...) { 40 | log_filter(.tbl, .fun = dplyr::distinct_at, .funname = "distinct_at", ...) 41 | } 42 | 43 | #' @export 44 | top_n <- function(x, ...) { 45 | log_filter(x, .fun = dplyr::top_n, .funname = "top_n", ...) 46 | } 47 | 48 | #' @export 49 | top_frac <- function(x, ...) { 50 | log_filter(x, .fun = dplyr::top_frac, .funname = "top_frac", ...) 51 | } 52 | 53 | #' @export 54 | sample_n <- function(tbl, ...) { 55 | log_filter(tbl, .fun = dplyr::sample_n, .funname = "sample_n", ...) 56 | } 57 | 58 | #' @export 59 | sample_frac <- function(tbl, ...) { 60 | log_filter(tbl, .fun = dplyr::sample_frac, .funname = "sample_frac", ...) 61 | } 62 | 63 | #' @export 64 | slice <- function(.data, ...) { 65 | log_filter(.data, .fun = dplyr::slice, .funname = "slice", ...) 66 | } 67 | 68 | #' @export 69 | slice_head <- function(.data, ...) { 70 | log_filter(.data, .fun = dplyr::slice_head, .funname = "slice_head", ...) 71 | } 72 | 73 | #' @export 74 | slice_tail <- function(.data, ...) { 75 | log_filter(.data, .fun = dplyr::slice_tail, .funname = "slice_tail", ...) 76 | } 77 | 78 | #' @export 79 | slice_min <- function(.data, ...) { 80 | log_filter(.data, .fun = dplyr::slice_min, .funname = "slice_min", ...) 81 | } 82 | 83 | #' @export 84 | slice_max <- function(.data, ...) { 85 | log_filter(.data, .fun = dplyr::slice_max, .funname = "slice_max", ...) 86 | } 87 | 88 | #' @export 89 | slice_sample <- function(.data, ...) { 90 | log_filter(.data, .fun = dplyr::slice_sample, .funname = "slice_sample", ...) 91 | } 92 | 93 | #' @export 94 | drop_na <- function(data, ...) { 95 | log_filter(data, .fun = tidyr::drop_na, .funname = "drop_na", ...) 96 | } 97 | 98 | log_filter <- function(.data, .fun, .funname, ...) { 99 | newdata <- .fun(.data, ...) 100 | if (!"data.frame" %in% class(.data) | !should_display()) { 101 | return(newdata) 102 | } 103 | 104 | if (dplyr::is.grouped_df(newdata) == TRUE) { 105 | group_status <- " (grouped)" 106 | groups_diff <- dplyr::n_groups(.data) - dplyr::n_groups(newdata) 107 | group_desc <- glue::glue(" (removed {plural(groups_diff, 'group')}, {plural(dplyr::n_groups(newdata), 'group')} remaining)") 108 | } else { 109 | group_status <- "" 110 | group_desc <- "" 111 | } 112 | 113 | n <- nrow(.data) - nrow(newdata) 114 | if (n == 0) { 115 | display(glue::glue("{.funname}{group_status}: no rows removed")) 116 | } else if (n == nrow(.data)) { 117 | display(glue::glue("{.funname}{group_status}: removed all rows (100%)")) 118 | } else { 119 | total <- nrow(.data) 120 | display(glue::glue("{.funname}{group_status}: ", 121 | "removed {plural(n, 'row')} ", 122 | "({percent(n, {total})}), {plural(nrow(newdata), 'row')} remaining{group_desc}")) 123 | } 124 | newdata 125 | } 126 | -------------------------------------------------------------------------------- /R/group_by.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | group_by <- function(.data, ...) { 3 | log_group_by(.data, .fun = dplyr::group_by, .funname = "group_by", ...) 4 | } 5 | 6 | #' @export 7 | group_by_all <- function(.tbl, ...) { 8 | log_group_by(.tbl, .fun = dplyr::group_by_all, .funname = "group_by_all", ...) 9 | } 10 | 11 | #' @export 12 | group_by_if <- function(.tbl, ...) { 13 | log_group_by(.tbl, .fun = dplyr::group_by_if, .funname = "group_by_if", ...) 14 | } 15 | 16 | #' @export 17 | group_by_at <- function(.tbl, ...) { 18 | log_group_by(.tbl, .fun = dplyr::group_by_at, .funname = "group_by_at", ...) 19 | } 20 | 21 | #' @export 22 | ungroup <- function(x, ...) { 23 | log_group_by(x, .fun = dplyr::ungroup, .funname = "ungroup", ...) 24 | } 25 | 26 | log_group_by <- function(.data, .fun, .funname, ...) { 27 | newdata <- .fun(.data, ...) 28 | if (!"data.frame" %in% class(.data) | !should_display()) { 29 | return(newdata) 30 | } 31 | group_vars <- get_groups(newdata) 32 | if (is.null(group_vars)) { 33 | display(glue::glue("{.funname}: no grouping variables remain")) 34 | } else { 35 | display(glue::glue( 36 | "{.funname}: {plural(length(group_vars), 'grouping variable')} ", 37 | "({format_list(group_vars)})")) 38 | } 39 | newdata 40 | } 41 | -------------------------------------------------------------------------------- /R/join.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | inner_join <- function(x, y, by = NULL, ...) { 3 | log_join(x, y, by, 4 | .fun = dplyr::inner_join, .funname = "inner_join", 5 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 6 | } 7 | 8 | #' @export 9 | full_join <- function(x, y, by = NULL, ...) { 10 | log_join(x, y, by, 11 | .fun = dplyr::full_join, .funname = "full_join", 12 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 13 | } 14 | 15 | #' @export 16 | left_join <- function(x, y, by = NULL, ...) { 17 | log_join(x, y, by, 18 | .fun = dplyr::left_join, .funname = "left_join", 19 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 20 | } 21 | 22 | #' @export 23 | right_join <- function(x, y, by = NULL, ...) { 24 | log_join(x, y, by, 25 | .fun = dplyr::right_join, .funname = "right_join", 26 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 27 | } 28 | 29 | #' @export 30 | anti_join <- function(x, y, by = NULL, ...) { 31 | log_join(x, y, by, 32 | .fun = dplyr::anti_join, .funname = "anti_join", 33 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 34 | } 35 | 36 | #' @export 37 | semi_join <- function(x, y, by = NULL, ...) { 38 | log_join(x, y, by, 39 | .fun = dplyr::semi_join, .funname = "semi_join", 40 | .name_x = deparse1(substitute(x)), .name_y = deparse1(substitute(y)), ...) 41 | } 42 | 43 | log_join <- function(x, y, by, .fun, .funname, .name_x, .name_y, ...) { 44 | newdata <- .fun(x, y, by, ...) 45 | if (!"data.frame" %in% class(x) | !should_display()) { 46 | return(newdata) 47 | } 48 | 49 | # columns 50 | cols <- setdiff(names(newdata), names(x)) 51 | if (length(cols) == 0) { 52 | display(glue::glue("{.funname}: added no columns")) 53 | } else { 54 | display(glue::glue("{.funname}: ", 55 | "added {plural(length(cols), 'column')} ({format_list(cols)})")) 56 | } 57 | 58 | # figure out matched in rows 59 | if ("dplyr_join_by" %in% class(by)) { 60 | if (all(by$condition == "==")) { 61 | keys <- by 62 | } else { 63 | return(newdata) 64 | } 65 | 66 | } else { 67 | keys <- suppressMessages(dplyr::common_by(by = by, x = x, y = y)) 68 | } 69 | cols_x <- x[, keys$x, drop = FALSE] 70 | cols_y <- y[, keys$y, drop = FALSE] 71 | 72 | only_in_x <- suppressMessages(dplyr::anti_join(cols_x, cols_y, 73 | by = stats::setNames(keys$y, keys$x))) 74 | only_in_y <- suppressMessages(dplyr::anti_join(cols_y, cols_x, 75 | by = stats::setNames(keys$x, keys$y))) 76 | 77 | stats <- list( 78 | only_in_x = nrow(only_in_x), 79 | only_in_y = nrow(only_in_y), 80 | total = nrow(newdata) 81 | ) 82 | 83 | # figure out matched & duplicates 84 | duplicates <- "" 85 | if (.funname == "inner_join") { 86 | stats$matched <- stats$total 87 | 88 | if (stats$matched > (nrow(x) - stats$only_in_x)) 89 | duplicates <- " (includes duplicates)" 90 | } else if (.funname == "full_join") { 91 | stats$matched <- stats$total - stats$only_in_x - stats$only_in_y 92 | 93 | if (stats$matched > (nrow(x) - stats$only_in_x)) 94 | duplicates <- " (includes duplicates)" 95 | } else if (.funname == "left_join") { 96 | stats$matched <- stats$total - stats$only_in_x 97 | 98 | if (stats$matched > (nrow(x) - stats$only_in_x)) 99 | duplicates <- " (includes duplicates)" 100 | } else if (.funname == "right_join") { 101 | stats$matched <- stats$total - stats$only_in_y 102 | 103 | if (stats$matched > (nrow(y) - stats$only_in_y)) 104 | duplicates <- " (includes duplicates)" 105 | } else if (.funname == "anti_join") { 106 | stats$matched <- nrow(x) - stats$total 107 | # by definition, no duplicates 108 | } else if (.funname == "semi_join") { 109 | stats$matched <- stats$total 110 | # by definition, no duplicates 111 | } 112 | 113 | # format to same width 114 | stats_str <- lapply(stats, function(x) formatC(x, big.mark = ",")) 115 | max_n <- max(sapply(stats_str, nchar)) 116 | stats_str <- lapply(stats_str, function(x) format(x, justify = "right", width = max_n)) 117 | # data set names 118 | .name_x <- ifelse(.name_x == ".", "x", shorten(.name_x)) 119 | .name_y <- ifelse(.name_y == ".", "y", shorten(.name_y)) 120 | names_length <- max(nchar(.name_x), nchar(.name_y)) 121 | .name_x <- format(.name_x, justify = "left", width = names_length) 122 | .name_y <- format(.name_y, justify = "left", width = names_length) 123 | # white space 124 | ws_pre <- paste0(rep(" ", nchar(.funname)), collapse = "") 125 | ws_post <- paste0(rep(" ", names_length), collapse = "") 126 | 127 | if (.funname %in% c("right_join", "inner_join", "semi_join")) { 128 | display(glue::glue("{ws_pre} > rows only in {.name_x} ({stats_str$only_in_x})")) 129 | } else { 130 | display(glue::glue("{ws_pre} > rows only in {.name_x} {stats_str$only_in_x}")) 131 | } 132 | if (.funname %in% c("left_join", "inner_join", "semi_join", "anti_join")) { 133 | display(glue::glue("{ws_pre} > rows only in {.name_y} ({stats_str$only_in_y})")) 134 | } else { 135 | display(glue::glue("{ws_pre} > rows only in {.name_y} {stats_str$only_in_y}")) 136 | } 137 | if (.funname == "anti_join") { 138 | display(glue::glue("{ws_pre} > matched rows{ws_post} ({stats_str$matched})")) 139 | } else { 140 | display(glue::glue("{ws_pre} > matched rows{ws_post} {stats_str$matched}{duplicates}")) 141 | } 142 | display(glue::glue("{ws_pre} >{ws_post} ={paste0(rep('=', max_n), collapse = '')}=")) 143 | display(glue::glue("{ws_pre} > rows total{ws_post} {stats_str$total}")) 144 | 145 | newdata 146 | } 147 | -------------------------------------------------------------------------------- /R/longer_wider.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | pivot_longer <- function(data, ...) { 3 | log_longer_wider(data, .fun = tidyr::pivot_longer, .funname = "pivot_longer", ...) 4 | } 5 | 6 | #' @export 7 | pivot_wider <- function(data, ...) { 8 | log_longer_wider(data, .fun = tidyr::pivot_wider, .funname = "pivot_wider", ...) 9 | } 10 | 11 | #' @export 12 | gather <- function(data, ...) { 13 | log_longer_wider(data, .fun = tidyr::gather, .funname = "gather", ...) 14 | } 15 | 16 | 17 | #' @export 18 | spread <- function(data, ...) { 19 | log_longer_wider(data, .fun = tidyr::spread, .funname = "spread", ...) 20 | } 21 | 22 | #' @export 23 | separate_wider_position <- function(data, ...) { 24 | log_longer_wider(data, .fun = tidyr::separate_wider_position, .funname = "separate_wider_position", ...) 25 | } 26 | 27 | #' @export 28 | separate_wider_delim <- function(data, ...) { 29 | log_longer_wider(data, .fun = tidyr::separate_wider_delim, .funname = "separate_wider_delim", ...) 30 | } 31 | 32 | #' @export 33 | separate_wider_regex <- function(data, ...) { 34 | log_longer_wider(data, .fun = tidyr::separate_wider_regex, .funname = "separate_wider_regex", ...) 35 | } 36 | 37 | 38 | log_longer_wider <- function(.data, .fun, .funname, ...) { 39 | newdata <- .fun(.data, ...) 40 | 41 | if (!"data.frame" %in% class(.data) | !should_display()) { 42 | return(newdata) 43 | } 44 | 45 | newcols <- setdiff(names(newdata), names(.data)) 46 | oldcols <- setdiff(names(.data), names(newdata)) 47 | 48 | display(glue::glue( 49 | "{.funname}: ", 50 | "reorganized ({format_list(oldcols)}) ", 51 | "into ({format_list(newcols)}) ", 52 | "[was {nrow(.data)}x{ncol(.data)}, ", 53 | "now {nrow(newdata)}x{ncol(newdata)}]" 54 | )) 55 | 56 | newdata 57 | } 58 | -------------------------------------------------------------------------------- /R/mutate.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | mutate <- function(.data, ...) { 3 | log_mutate(.data, .fun = dplyr::mutate, .funname = "mutate", ...) 4 | } 5 | 6 | #' @export 7 | mutate_all <- function(.tbl, ...) { 8 | log_mutate(.tbl, .fun = dplyr::mutate_all, .funname = "mutate_all", ...) 9 | } 10 | 11 | #' @export 12 | mutate_if <- function(.tbl, ...) { 13 | log_mutate(.tbl, .fun = dplyr::mutate_if, .funname = "mutate_if", ...) 14 | } 15 | 16 | #' @export 17 | mutate_at <- function(.tbl, ...) { 18 | log_mutate(.tbl, .fun = dplyr::mutate_at, .funname = "mutate_at", ...) 19 | } 20 | 21 | #' @export 22 | transmute <- function(.data, ...) { 23 | log_mutate(.data, .fun = dplyr::transmute, .funname = "transmute", ...) 24 | } 25 | 26 | #' @export 27 | transmute_all <- function(.tbl, ...) { 28 | log_mutate(.tbl, .fun = dplyr::transmute_all, .funname = "transmute_all", ...) 29 | } 30 | 31 | #' @export 32 | transmute_if <- function(.tbl, ...) { 33 | log_mutate(.tbl, .fun = dplyr::transmute_if, .funname = "transmute_if", ...) 34 | } 35 | 36 | #' @export 37 | transmute_at <- function(.tbl, ...) { 38 | log_mutate(.tbl, .fun = dplyr::transmute_at, .funname = "transmute_at", ...) 39 | } 40 | 41 | #' @export 42 | add_tally <- function(x, ...) { 43 | log_mutate(x, .fun = dplyr::add_tally, .funname = "add_tally", ...) 44 | } 45 | 46 | #' @export 47 | add_count <- function(x, ...) { 48 | log_mutate(x, .fun = dplyr::add_count, .funname = "add_count", ...) 49 | } 50 | 51 | #' @export 52 | replace_na <- function(data, ...) { 53 | log_mutate(data, .fun = tidyr::replace_na, .funname = "replace_na", ...) 54 | } 55 | 56 | #' @export 57 | fill <- function(data, ...) { 58 | log_mutate(data, .fun = tidyr::fill, .funname = "fill", ...) 59 | } 60 | 61 | log_mutate <- function(.data, .fun, .funname, ...) { 62 | cols <- names(.data) 63 | newdata <- .fun(.data, ...) 64 | 65 | if (!"data.frame" %in% class(.data) | !should_display()) { 66 | return(newdata) 67 | } 68 | 69 | # add group status 70 | prefix <- ifelse(dplyr::is.grouped_df(newdata), 71 | glue::glue("{.funname} (grouped):"), 72 | glue::glue("{.funname}:")) 73 | 74 | if (grepl("transmute", .funname)) { 75 | dropped_vars <- setdiff(names(.data), names(newdata)) 76 | n <- length(dropped_vars) 77 | if (ncol(newdata) == 0) { 78 | display(glue::glue("{prefix} dropped all variables")) 79 | return(newdata) 80 | } else if (length(dropped_vars) > 0) { 81 | display(glue::glue("{prefix} dropped {plural(n, 'variable')}", 82 | " ({format_list(dropped_vars)})")) 83 | # replace by spaces 84 | prefix <- paste0(rep(" ", nchar(prefix)), collapse = "") 85 | } 86 | } 87 | 88 | has_changed <- FALSE 89 | 90 | dropped_vars <- setdiff(cols, names(newdata)) 91 | if (length(dropped_vars) > 0) { 92 | # dropped only 93 | display(glue::glue("{.funname}: dropped {plural(length(dropped_vars), 'variable')}", 94 | " ({format_list(dropped_vars)})")) 95 | has_changed = TRUE 96 | } 97 | 98 | for (var in names(newdata)) { 99 | # new var 100 | if (!var %in% cols) { 101 | has_changed <- TRUE 102 | n <- length(unique(newdata[[var]])) 103 | p_na <- percent(sum(is.na(newdata[[var]])), length(newdata[[var]])) 104 | display(glue::glue("{prefix} new variable '{var}' ({get_type(newdata[[var]])}) ", 105 | "with {plural(n, 'value', 'unique ')} and {p_na} NA")) 106 | # replace by spaces 107 | prefix <- paste0(rep(" ", nchar(prefix)), collapse = "") 108 | } else { 109 | # existing var 110 | # use identical to account for missing values - this is fast 111 | if (identical(newdata[[var]], .data[[var]])) { 112 | next 113 | } 114 | has_changed <- TRUE 115 | old <- .data[[var]] 116 | new <- newdata[[var]] 117 | typeold <- get_type(old) 118 | typenew <- get_type(new) 119 | 120 | if (typeold %in% c("factor", "ordered factor") & 121 | typenew %in% c("factor", "ordered factor")) { 122 | # when factor, compare based on character values 123 | # this will include both changes in the factor levels and recodes 124 | old <- as.character(old) 125 | new <- as.character(new) 126 | } 127 | 128 | if (typeold == typenew) { 129 | # same type 130 | if (typeold == "list") { 131 | different <- sapply(seq_len(length(new)), 132 | function(i) !identical(new[[i]], old[[i]])) 133 | } else { 134 | different <- new != old 135 | different[is.na(new) & !is.na(old)] <- TRUE 136 | different[!is.na(new) & is.na(old)] <- TRUE 137 | different[is.na(new) & is.na(old)] <- FALSE 138 | } 139 | n <- sum(different) 140 | p <- percent(n, length(different)) 141 | new_na <- sum(is.na(new)) - sum(is.na(old)) 142 | na_text <- plural(abs(new_na), "NA", mid = ifelse(new_na >= 0, "new ", "fewer ")) 143 | display(glue::glue("{prefix} changed {plural(n, 'value')} ", 144 | "({p}) of '{var}' ({na_text})")) 145 | # replace by spaces 146 | prefix <- paste0(rep(" ", nchar(prefix)), collapse = "") 147 | } else { 148 | # different type 149 | new_na <- sum(is.na(new)) - sum(is.na(old)) 150 | if (new_na == length(new)) { 151 | display(glue::glue("{prefix} converted '{var}' from {typeold}", 152 | " to {typenew} (now 100% NA)")) 153 | # replace by spaces 154 | prefix <- paste0(rep(" ", nchar(prefix)), collapse = "") 155 | } else { 156 | na_text <- glue::glue("{abs(new_na)} ", 157 | ifelse(new_na >= 0, "new", "fewer"), " NA") 158 | display(glue::glue("{prefix} converted '{var}' from {typeold}", 159 | " to {typenew} ({na_text})")) 160 | # replace by spaces 161 | prefix <- paste0(rep(" ", nchar(prefix)), collapse = "") 162 | } 163 | } 164 | } 165 | } 166 | 167 | if (!has_changed) { 168 | display(glue::glue("{prefix} no changes")) 169 | } 170 | newdata 171 | } 172 | -------------------------------------------------------------------------------- /R/rename.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | rename <- function(.data, ...) { 3 | log_rename(.data, .fun = dplyr::rename, .funname = "rename", ...) 4 | } 5 | 6 | #' @export 7 | rename_all <- function(.tbl, ...) { 8 | log_rename(.tbl, .fun = dplyr::rename_all, .funname = "rename_all", ...) 9 | } 10 | 11 | #' @export 12 | rename_if <- function(.tbl, ...) { 13 | log_rename(.tbl, .fun = dplyr::rename_if, .funname = "rename_if", ...) 14 | } 15 | 16 | #' @export 17 | rename_at <- function(.tbl, ...) { 18 | log_rename(.tbl, .fun = dplyr::rename_at, .funname = "rename_at", ...) 19 | } 20 | 21 | #' @export 22 | rename_with <- function(.data, ...) { 23 | log_rename(.data, .fun = dplyr::rename_with, .funname = "rename_with", ...) 24 | } 25 | 26 | log_rename <- function(.data, .fun, .funname, ...) { 27 | cols <- names(.data) 28 | newdata <- .fun(.data, ...) 29 | if (!"data.frame" %in% class(.data) | !should_display()) { 30 | return(newdata) 31 | } 32 | renamed_cols <- setdiff(names(newdata), cols) 33 | n <- length(renamed_cols) 34 | if (n > 0) { 35 | display(glue::glue("{.funname}: renamed {plural(n, 'variable')}", 36 | " ({format_list(renamed_cols)})")) 37 | } 38 | newdata 39 | } 40 | -------------------------------------------------------------------------------- /R/select.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | select <- function(.data, ...) { 3 | log_select(.data, .fun = dplyr::select, .funname = "select", ...) 4 | } 5 | 6 | #' @export 7 | select_all <- function(.tbl, ...) { 8 | log_select(.tbl, .fun = dplyr::select_all, .funname = "select_all", ...) 9 | } 10 | 11 | #' @export 12 | select_if <- function(.tbl, ...) { 13 | log_select(.tbl, .fun = dplyr::select_if, .funname = "select_if", ...) 14 | } 15 | 16 | #' @export 17 | select_at <- function(.tbl, ...) { 18 | log_select(.tbl, .fun = dplyr::select_at, .funname = "select_at", ...) 19 | } 20 | 21 | #' @export 22 | relocate <- function(.data, ...) { 23 | log_select(.data, .fun = dplyr::relocate, .funname = "relocate", ...) 24 | } 25 | 26 | log_select <- function(.data, .fun, .funname, ...) { 27 | cols <- names(.data) 28 | newdata <- .fun(.data, ...) 29 | if (!"data.frame" %in% class(.data) | !should_display()) { 30 | return(newdata) 31 | } 32 | 33 | dropped_vars <- setdiff(cols, names(newdata)) 34 | renamed_vars <- setdiff(names(newdata), cols) 35 | 36 | if (ncol(newdata) == 0) { 37 | display(glue::glue("{.funname}: dropped all variables")) 38 | } else if (length(renamed_vars) > 0 & length(renamed_vars) == length(dropped_vars)) { 39 | # renamed only 40 | display(glue::glue("{.funname}: renamed {plural(length(renamed_vars), 'variable')}", 41 | " ({format_list(renamed_vars)})")) 42 | } else if (length(dropped_vars) > 0 & length(renamed_vars) > 0) { 43 | # dropped & renamed 44 | n_dropped <- length(dropped_vars) - length(renamed_vars) 45 | display(glue::glue("{.funname}: ", 46 | "renamed {plural(length(renamed_vars), 'variable')}", 47 | " ({format_list(renamed_vars)})", 48 | " and dropped {plural(n_dropped, 'variable')}")) 49 | } else if (length(dropped_vars) > 0) { 50 | # dropped only 51 | display(glue::glue("{.funname}: dropped {plural(length(dropped_vars), 'variable')}", 52 | " ({format_list(dropped_vars)})")) 53 | } else { 54 | # no dropped, no removed 55 | if (all(names(newdata) == cols)) { 56 | display(glue::glue("{.funname}: no changes")) 57 | } else { 58 | display(glue::glue("{.funname}: columns reordered", 59 | " ({format_list(names(newdata))})")) 60 | } 61 | } 62 | 63 | newdata 64 | } 65 | -------------------------------------------------------------------------------- /R/summarize.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | summarize <- function(.data, ...) { 3 | log_summarize(.data, .fun = dplyr::summarize, .funname = "summarize", ...) 4 | } 5 | 6 | #' @export 7 | summarize_all <- function(.tbl, ...) { 8 | log_summarize(.tbl, .fun = dplyr::summarize_all, .funname = "summarize_all", ...) 9 | } 10 | 11 | #' @export 12 | summarize_at <- function(.tbl, ...) { 13 | log_summarize(.tbl, .fun = dplyr::summarize_at, .funname = "summarize_at", ...) 14 | } 15 | 16 | #' @export 17 | summarize_if <- function(.tbl, ...) { 18 | log_summarize(.tbl, .fun = dplyr::summarize_if, .funname = "summarize_if", ...) 19 | } 20 | 21 | #' @export 22 | summarise <- function(.data, ...) { 23 | log_summarize(.data, .fun = dplyr::summarise, .funname = "summarise", ...) 24 | } 25 | 26 | #' @export 27 | summarise_all <- function(.tbl, ...) { 28 | log_summarize(.tbl, .fun = dplyr::summarise_all, .funname = "summarise_all", ...) 29 | } 30 | 31 | #' @export 32 | summarise_at <- function(.tbl, ...) { 33 | log_summarize(.tbl, .fun = dplyr::summarise_at, .funname = "summarise_at", ...) 34 | } 35 | 36 | #' @export 37 | summarise_if <- function(.tbl, ...) { 38 | log_summarize(.tbl, .fun = dplyr::summarise_if, .funname = "summarise_if", ...) 39 | } 40 | 41 | #' @export 42 | tally <- function(x, ...) { 43 | log_summarize(x, .fun = dplyr::tally, .funname = "tally", ...) 44 | } 45 | 46 | #' @export 47 | count <- function(x, ...) { 48 | log_summarize(x, .fun = dplyr::count, .funname = "count", ...) 49 | } 50 | 51 | #' @export 52 | uncount <- function(data, ...) { 53 | log_summarize(data, .fun = tidyr::uncount, .funname = "uncount", ...) 54 | } 55 | 56 | log_summarize <- function(.data, .fun, .funname, ...) { 57 | newdata <- .fun(.data, ...) 58 | 59 | if (!"data.frame" %in% class(.data) | !should_display()) { 60 | return(newdata) 61 | } 62 | 63 | group_vars <- get_groups(newdata) 64 | group_length <- length(group_vars) 65 | if (group_length > 0) { 66 | display(glue::glue( 67 | "{.funname}: now {plural(nrow(newdata), 'row')} and ", 68 | "{plural(ncol(newdata), 'column')}, ", 69 | "{plural(group_length, 'group variable')} remaining ", 70 | "({format_list(group_vars)})")) 71 | } else { 72 | display(glue::glue( 73 | "{.funname}: now {plural(nrow(newdata), 'row')} and ", 74 | "{plural(ncol(newdata), 'column')}, ungrouped")) 75 | } 76 | 77 | newdata 78 | } 79 | -------------------------------------------------------------------------------- /R/tidylog.R: -------------------------------------------------------------------------------- 1 | plural <- function(n_items, noun, mid = "") { 2 | if (n_items == 1) { 3 | paste0("one ", mid, noun) 4 | } else { 5 | paste0(format(n_items, big.mark = ",", scientific = FALSE), " ", mid, noun, "s") 6 | } 7 | } 8 | 9 | shorten <- function(str) { 10 | if (nchar(str) > 25) { 11 | paste0(substr(str, 1, 23), "..") 12 | } else { 13 | str 14 | } 15 | } 16 | 17 | percent <- function(n, total) { 18 | p <- round(n / total * 100) 19 | if (n == total) { 20 | "100%" 21 | } else if (p == 100) { 22 | ">99%" 23 | } else if (n == 0) { 24 | "0%" 25 | } else if (p == 0) { 26 | "<1%" 27 | } else { 28 | paste0(p, "%") 29 | } 30 | } 31 | 32 | format_list <- function(items) { 33 | if (length(items) <= 5) { 34 | paste0(items, collapse = ", ") 35 | } else { 36 | paste0(c(items[1:5], cli::symbol$ellipsis), collapse = ", ") 37 | } 38 | } 39 | 40 | get_type <- function(v) { 41 | if (is.ordered(v)) { 42 | "ordered factor" 43 | } else if (is.factor(v)) { 44 | "factor" 45 | } else if (inherits(v, "Date")) { 46 | "Date" 47 | } else if (inherits(v, "units")) { 48 | "units" 49 | } else { 50 | typeof(v) 51 | } 52 | } 53 | 54 | get_groups <- function(.data) { 55 | if (!is.null(attr(.data, "groups"))) { 56 | # support for dplyr >= 0.8 57 | groups <- attr(.data, "groups") 58 | return(utils::head(names(groups), -1)) 59 | } else { 60 | # support for dplyr < 0.8 61 | return(attr(.data, "vars")) 62 | } 63 | } 64 | 65 | #' @import rlang 66 | display <- function(text) { 67 | functions <- getOption("tidylog.display") 68 | if (is.null(functions)) { 69 | rlang::inform(text) 70 | } else if (is.list(functions)) { 71 | for (f in functions) { 72 | if (is.function(f)) { 73 | f(text) 74 | } else { 75 | warning("tidylog.display needs to be set to either NULL or a list of functions") 76 | } 77 | } 78 | } else { 79 | warning("tidylog.display needs to be set to either NULL or a list of functions") 80 | } 81 | } 82 | 83 | should_display <- function() { 84 | is.null(getOption("tidylog.display")) | length(getOption("tidylog.display")) > 0 85 | } 86 | 87 | #' outputs some information about the data frame/tbl 88 | #' 89 | #' @param .data a tbl/data frame 90 | #' @return same as .data 91 | #' @examples 92 | #' tidylog(mtcars) 93 | #' #> tidylog: data.frame with 32 rows and 11 columns 94 | #' @export 95 | tidylog <- function(.data) { 96 | if (!"data.frame" %in% class(.data) | !should_display()) { 97 | return(.data) 98 | } 99 | 100 | if ("grouped_df" %in% class(.data)) { 101 | type <- glue::glue("grouped tibble") 102 | } else if ("tbl" %in% class(.data)) { 103 | type <- "tibble" 104 | } else if ("data.table" %in% class(.data)) { 105 | type <- "data.table" 106 | } else { 107 | type <- "data.frame" 108 | } 109 | 110 | display(glue::glue("tidylog: {type} with {plural(nrow(.data), 'row')} and ", 111 | "{plural(ncol(.data), 'column')}")) 112 | .data 113 | } 114 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r setup, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | # tidylog 16 | 17 | [![CRAN Version](https://www.r-pkg.org/badges/version/tidylog)](https://CRAN.R-project.org/package=tidylog) 18 | [![Downloads](http://cranlogs.r-pkg.org/badges/tidylog)](https://CRAN.R-project.org/package=tidylog) 19 | [![R-CMD-check](https://github.com/elbersb/tidylog/workflows/R-CMD-check/badge.svg)](https://github.com/elbersb/tidylog/actions) 20 | [![Coverage status](https://codecov.io/gh/elbersb/tidylog/branch/master/graph/badge.svg)](https://app.codecov.io/github/elbersb/tidylog?branch=master) 21 | 22 | The goal of tidylog is to provide feedback about dplyr and tidyr operations. It provides simple wrapper functions for almost all dplyr and tidyr functions, such as `filter`, `mutate`, `select`, `full_join`, and `group_by`. 23 | 24 | ## Example 25 | 26 | Load `tidylog` after `dplyr` and/or `tidyr`: 27 | 28 | ```{r message=FALSE, warning=FALSE} 29 | library("dplyr") 30 | library("tidyr") 31 | library("tidylog", warn.conflicts = FALSE) 32 | ``` 33 | 34 | Tidylog will give you feedback, for instance when filtering a data frame or adding a new variable: 35 | 36 | ```{r} 37 | filtered <- filter(mtcars, cyl == 4) 38 | mutated <- mutate(mtcars, new_var = wt ** 2) 39 | ``` 40 | 41 | Tidylog reports detailed information for joins: 42 | 43 | ```{r} 44 | joined <- left_join(nycflights13::flights, nycflights13::weather, 45 | by = c("year", "month", "day", "origin", "hour", "time_hour")) 46 | ``` 47 | 48 | In this case, we see that 1,556 rows from the `flights` dataset do not have weather information. 49 | 50 | Tidylog can be especially helpful in longer pipes: 51 | 52 | ```{r} 53 | summary <- mtcars %>% 54 | select(mpg, cyl, hp, am) %>% 55 | filter(mpg > 15) %>% 56 | mutate(mpg_round = round(mpg)) %>% 57 | group_by(cyl, mpg_round, am) %>% 58 | tally() %>% 59 | filter(n >= 1) 60 | ``` 61 | Here, it might have been accidental that the last `filter` command had no effect. 62 | 63 | ## Installation 64 | 65 | Download from CRAN: 66 | 67 | ``` r 68 | install.packages("tidylog") 69 | ``` 70 | 71 | Or install the development version: 72 | 73 | ``` r 74 | devtools::install_github("elbersb/tidylog") 75 | ``` 76 | 77 | ## Benchmarks 78 | 79 | Tidylog will add a small overhead to each function call. This can be relevant for very large datasets and especially for joins. If you want to switch off tidylog for a single long-running command, simply prefix `dplyr::` or `tidyr::`, such as in `dplyr::left_join`. See [this vignette](https://cran.r-project.org/package=tidylog/vignettes/benchmarks.html) for more information. 80 | 81 | ## More examples 82 | 83 | ### filter, distinct, drop_na 84 | 85 | ```{r} 86 | a <- filter(mtcars, mpg > 20) 87 | b <- filter(mtcars, mpg > 100) 88 | c <- filter(mtcars, mpg > 0) 89 | d <- filter_at(mtcars, vars(starts_with("d")), any_vars((. %% 2) == 0)) 90 | e <- distinct(mtcars) 91 | f <- distinct_at(mtcars, vars(vs:carb)) 92 | g <- top_n(mtcars, 2, am) 93 | i <- sample_frac(mtcars, 0.5) 94 | 95 | j <- drop_na(airquality) 96 | k <- drop_na(airquality, Ozone) 97 | ``` 98 | 99 | ### mutate, transmute, replace_na, fill 100 | 101 | ```{r} 102 | a <- mutate(mtcars, new_var = 1) 103 | b <- mutate(mtcars, new_var = runif(n())) 104 | c <- mutate(mtcars, new_var = NA) 105 | d <- mutate_at(mtcars, vars(mpg, gear, drat), round) 106 | e <- mutate(mtcars, am_factor = as.factor(am)) 107 | f <- mutate(mtcars, am = as.ordered(am)) 108 | g <- mutate(mtcars, am = ifelse(am == 1, NA, am)) 109 | h <- mutate(mtcars, am = recode(am, `0` = "zero", `1` = NA_character_)) 110 | 111 | i <- transmute(mtcars, mpg = mpg * 2, gear = gear + 1, new_var = vs + am) 112 | 113 | j <- replace_na(airquality, list(Solar.R = 1)) 114 | k <- fill(airquality, Ozone) 115 | ``` 116 | 117 | ### joins 118 | 119 | For joins, tidylog provides more detailed information. For any join, 120 | tidylog will show the number of rows 121 | that are only present in x (the first dataframe), only present in y (the second dataframe), 122 | and rows that have been matched. Numbers in parentheses indicate that these rows are not 123 | included in the result. Tidylog will also indicate whether any rows were duplicated 124 | (which is often unintentional): 125 | 126 | ```{r} 127 | x <- tibble(a = 1:2) 128 | y <- tibble(a = c(1, 1, 2), b = 1:3) # 1 is duplicated 129 | j <- left_join(x, y, by = "a") 130 | ``` 131 | 132 | More examples: 133 | 134 | ```{r} 135 | a <- left_join(band_members, band_instruments, by = "name") 136 | b <- full_join(band_members, band_instruments, by = "name") 137 | c <- anti_join(band_members, band_instruments, by = "name") 138 | ``` 139 | 140 | Because tidylog needs to perform two additional joins behind the scenes to report this information, 141 | the overhead will be larger than for the other tidylog functions (especially with large datasets). 142 | 143 | ### select, relocate, rename 144 | 145 | ```{r} 146 | a <- select(mtcars, mpg, wt) 147 | b <- select_if(mtcars, is.character) 148 | c <- relocate(mtcars, hp) 149 | d <- select(mtcars, a = wt, b = mpg) 150 | 151 | e <- rename(mtcars, miles_per_gallon = mpg) 152 | f <- rename_with(mtcars, toupper) 153 | ``` 154 | 155 | ### summarize 156 | 157 | ```{r} 158 | a <- mtcars %>% 159 | group_by(cyl, carb) %>% 160 | summarize(total_weight = sum(wt)) 161 | 162 | b <- iris %>% 163 | group_by(Species) %>% 164 | summarize_all(list(min, max)) 165 | ``` 166 | 167 | ### tally, count, add_tally, add_count 168 | 169 | ```{r} 170 | a <- mtcars %>% group_by(gear, carb) %>% tally 171 | b <- mtcars %>% group_by(gear, carb) %>% add_tally() 172 | 173 | c <- mtcars %>% count(gear, carb) 174 | d <- mtcars %>% add_count(gear, carb, name = "count") 175 | ``` 176 | 177 | ### pivot_longer, pivot_wider 178 | 179 | ```{r} 180 | longer <- mtcars %>% 181 | mutate(id = 1:n()) %>% 182 | pivot_longer(-id, names_to = "var", values_to = "value") 183 | wider <- longer %>% 184 | pivot_wider(names_from = var, values_from = value) 185 | ``` 186 | 187 | Tidylog also supports `gather` and `spread`. 188 | 189 | ## Turning logging off, registering additional loggers 190 | 191 | To turn off the output for just a particular function call, you can simply call the dplyr and tidyr functions 192 | directly, e.g. `dplyr::filter` or `tidyr::drop_na`. 193 | 194 | To turn off the output more permanently, set the global option `tidylog.display` to an empty list: 195 | 196 | ```{r} 197 | options("tidylog.display" = list()) # turn off 198 | a <- filter(mtcars, mpg > 20) 199 | 200 | options("tidylog.display" = NULL) # turn on 201 | a <- filter(mtcars, mpg > 20) 202 | ``` 203 | 204 | This option can also be used to register additional loggers. The option `tidylog.display` expects 205 | a list of functions. By default (when `tidylog.display` is set to NULL), tidylog 206 | will use the `message` function to display the output, but if you prefer a more colorful output, 207 | simply overwrite the option: 208 | 209 | ```{r} 210 | library("crayon") # for terminal colors 211 | crayon <- function(x) cat(red$bold(x), sep = "\n") 212 | options("tidylog.display" = list(crayon)) 213 | a <- filter(mtcars, mpg > 20) 214 | ``` 215 | 216 | To print the output both to the screen and to a file, you could use: 217 | 218 | ```{r} 219 | log_to_file <- function(text) cat(text, file = "log.txt", sep = "\n", append = TRUE) 220 | options("tidylog.display" = list(message, log_to_file)) 221 | a <- filter(mtcars, mpg > 20) 222 | ``` 223 | 224 | ## Namespace conflicts 225 | 226 | Tidylog redefines several of the functions exported by dplyr and tidyr, so it should be loaded last, otherwise there will be no output. A more explicit way to resolve namespace conflicts is to use the [conflicted](https://CRAN.R-project.org/package=conflicted) package: 227 | 228 | ``` r 229 | library("dplyr") 230 | library("tidyr") 231 | library("tidylog") 232 | library("conflicted") 233 | for (f in getNamespaceExports("tidylog")) { 234 | conflicted::conflict_prefer(f, "tidylog", quiet = TRUE) 235 | } 236 | ``` 237 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # tidylog 5 | 6 | [![CRAN 7 | Version](https://www.r-pkg.org/badges/version/tidylog)](https://CRAN.R-project.org/package=tidylog) 8 | [![Downloads](http://cranlogs.r-pkg.org/badges/tidylog)](https://CRAN.R-project.org/package=tidylog) 9 | [![R-CMD-check](https://github.com/elbersb/tidylog/workflows/R-CMD-check/badge.svg)](https://github.com/elbersb/tidylog/actions) 10 | [![Coverage 11 | status](https://codecov.io/gh/elbersb/tidylog/branch/master/graph/badge.svg)](https://app.codecov.io/github/elbersb/tidylog?branch=master) 12 | 13 | The goal of tidylog is to provide feedback about dplyr and tidyr 14 | operations. It provides simple wrapper functions for almost all dplyr 15 | and tidyr functions, such as `filter`, `mutate`, `select`, `full_join`, 16 | and `group_by`. 17 | 18 | ## Example 19 | 20 | Load `tidylog` after `dplyr` and/or `tidyr`: 21 | 22 | ``` r 23 | library("dplyr") 24 | library("tidyr") 25 | library("tidylog", warn.conflicts = FALSE) 26 | ``` 27 | 28 | Tidylog will give you feedback, for instance when filtering a data frame 29 | or adding a new variable: 30 | 31 | ``` r 32 | filtered <- filter(mtcars, cyl == 4) 33 | #> filter: removed 21 rows (66%), 11 rows remaining 34 | mutated <- mutate(mtcars, new_var = wt ** 2) 35 | #> mutate: new variable 'new_var' (double) with 29 unique values and 0% NA 36 | ``` 37 | 38 | Tidylog reports detailed information for joins: 39 | 40 | ``` r 41 | joined <- left_join(nycflights13::flights, nycflights13::weather, 42 | by = c("year", "month", "day", "origin", "hour", "time_hour")) 43 | #> left_join: added 9 columns (temp, dewp, humid, wind_dir, wind_speed, …) 44 | #> > rows only in nycflights13::flights 1,556 45 | #> > rows only in nycflights13::weather ( 6,737) 46 | #> > matched rows 335,220 47 | #> > ========= 48 | #> > rows total 336,776 49 | ``` 50 | 51 | In this case, we see that 1,556 rows from the `flights` dataset do not 52 | have weather information. 53 | 54 | Tidylog can be especially helpful in longer pipes: 55 | 56 | ``` r 57 | summary <- mtcars %>% 58 | select(mpg, cyl, hp, am) %>% 59 | filter(mpg > 15) %>% 60 | mutate(mpg_round = round(mpg)) %>% 61 | group_by(cyl, mpg_round, am) %>% 62 | tally() %>% 63 | filter(n >= 1) 64 | #> select: dropped 7 variables (disp, drat, wt, qsec, vs, …) 65 | #> filter: removed 6 rows (19%), 26 rows remaining 66 | #> mutate: new variable 'mpg_round' (double) with 15 unique values and 0% NA 67 | #> group_by: 3 grouping variables (cyl, mpg_round, am) 68 | #> tally: now 20 rows and 4 columns, 2 group variables remaining (cyl, mpg_round) 69 | #> filter (grouped): no rows removed 70 | ``` 71 | 72 | Here, it might have been accidental that the last `filter` command had 73 | no effect. 74 | 75 | ## Installation 76 | 77 | Download from CRAN: 78 | 79 | ``` r 80 | install.packages("tidylog") 81 | ``` 82 | 83 | Or install the development version: 84 | 85 | ``` r 86 | devtools::install_github("elbersb/tidylog") 87 | ``` 88 | 89 | ## Benchmarks 90 | 91 | Tidylog will add a small overhead to each function call. This can be 92 | relevant for very large datasets and especially for joins. If you want 93 | to switch off tidylog for a single long-running command, simply prefix 94 | `dplyr::` or `tidyr::`, such as in `dplyr::left_join`. See [this 95 | vignette](https://cran.r-project.org/package=tidylog/vignettes/benchmarks.html) 96 | for more information. 97 | 98 | ## More examples 99 | 100 | ### filter, distinct, drop_na 101 | 102 | ``` r 103 | a <- filter(mtcars, mpg > 20) 104 | #> filter: removed 18 rows (56%), 14 rows remaining 105 | b <- filter(mtcars, mpg > 100) 106 | #> filter: removed all rows (100%) 107 | c <- filter(mtcars, mpg > 0) 108 | #> filter: no rows removed 109 | d <- filter_at(mtcars, vars(starts_with("d")), any_vars((. %% 2) == 0)) 110 | #> filter_at: removed 19 rows (59%), 13 rows remaining 111 | e <- distinct(mtcars) 112 | #> distinct: no rows removed 113 | f <- distinct_at(mtcars, vars(vs:carb)) 114 | #> distinct_at: removed 18 rows (56%), 14 rows remaining 115 | g <- top_n(mtcars, 2, am) 116 | #> top_n: removed 19 rows (59%), 13 rows remaining 117 | i <- sample_frac(mtcars, 0.5) 118 | #> sample_frac: removed 16 rows (50%), 16 rows remaining 119 | 120 | j <- drop_na(airquality) 121 | #> drop_na: removed 42 rows (27%), 111 rows remaining 122 | k <- drop_na(airquality, Ozone) 123 | #> drop_na: removed 37 rows (24%), 116 rows remaining 124 | ``` 125 | 126 | ### mutate, transmute, replace_na, fill 127 | 128 | ``` r 129 | a <- mutate(mtcars, new_var = 1) 130 | #> mutate: new variable 'new_var' (double) with one unique value and 0% NA 131 | b <- mutate(mtcars, new_var = runif(n())) 132 | #> mutate: new variable 'new_var' (double) with 32 unique values and 0% NA 133 | c <- mutate(mtcars, new_var = NA) 134 | #> mutate: new variable 'new_var' (logical) with one unique value and 100% NA 135 | d <- mutate_at(mtcars, vars(mpg, gear, drat), round) 136 | #> mutate_at: changed 28 values (88%) of 'mpg' (0 new NAs) 137 | #> changed 31 values (97%) of 'drat' (0 new NAs) 138 | e <- mutate(mtcars, am_factor = as.factor(am)) 139 | #> mutate: new variable 'am_factor' (factor) with 2 unique values and 0% NA 140 | f <- mutate(mtcars, am = as.ordered(am)) 141 | #> mutate: converted 'am' from double to ordered factor (0 new NA) 142 | g <- mutate(mtcars, am = ifelse(am == 1, NA, am)) 143 | #> mutate: changed 13 values (41%) of 'am' (13 new NAs) 144 | h <- mutate(mtcars, am = recode(am, `0` = "zero", `1` = NA_character_)) 145 | #> mutate: converted 'am' from double to character (13 new NA) 146 | 147 | i <- transmute(mtcars, mpg = mpg * 2, gear = gear + 1, new_var = vs + am) 148 | #> transmute: dropped 9 variables (cyl, disp, hp, drat, wt, …) 149 | #> transmute: dropped 9 variables (cyl, disp, hp, drat, wt, …) 150 | #> changed 32 values (100%) of 'mpg' (0 new NAs) 151 | #> changed 32 values (100%) of 'gear' (0 new NAs) 152 | #> new variable 'new_var' (double) with 3 unique values and 0% NA 153 | 154 | j <- replace_na(airquality, list(Solar.R = 1)) 155 | #> replace_na: changed 7 values (5%) of 'Solar.R' (7 fewer NAs) 156 | k <- fill(airquality, Ozone) 157 | #> fill: changed 37 values (24%) of 'Ozone' (37 fewer NAs) 158 | ``` 159 | 160 | ### joins 161 | 162 | For joins, tidylog provides more detailed information. For any join, 163 | tidylog will show the number of rows that are only present in x (the 164 | first dataframe), only present in y (the second dataframe), and rows 165 | that have been matched. Numbers in parentheses indicate that these rows 166 | are not included in the result. Tidylog will also indicate whether any 167 | rows were duplicated (which is often unintentional): 168 | 169 | ``` r 170 | x <- tibble(a = 1:2) 171 | y <- tibble(a = c(1, 1, 2), b = 1:3) # 1 is duplicated 172 | j <- left_join(x, y, by = "a") 173 | #> left_join: added one column (b) 174 | #> > rows only in x 0 175 | #> > rows only in y (0) 176 | #> > matched rows 3 (includes duplicates) 177 | #> > === 178 | #> > rows total 3 179 | ``` 180 | 181 | More examples: 182 | 183 | ``` r 184 | a <- left_join(band_members, band_instruments, by = "name") 185 | #> left_join: added one column (plays) 186 | #> > rows only in band_members 1 187 | #> > rows only in band_instruments (1) 188 | #> > matched rows 2 189 | #> > === 190 | #> > rows total 3 191 | b <- full_join(band_members, band_instruments, by = "name") 192 | #> full_join: added one column (plays) 193 | #> > rows only in band_members 1 194 | #> > rows only in band_instruments 1 195 | #> > matched rows 2 196 | #> > === 197 | #> > rows total 4 198 | c <- anti_join(band_members, band_instruments, by = "name") 199 | #> anti_join: added no columns 200 | #> > rows only in band_members 1 201 | #> > rows only in band_instruments (1) 202 | #> > matched rows (2) 203 | #> > === 204 | #> > rows total 1 205 | ``` 206 | 207 | Because tidylog needs to perform two additional joins behind the scenes 208 | to report this information, the overhead will be larger than for the 209 | other tidylog functions (especially with large datasets). 210 | 211 | ### select, relocate, rename 212 | 213 | ``` r 214 | a <- select(mtcars, mpg, wt) 215 | #> select: dropped 9 variables (cyl, disp, hp, drat, qsec, …) 216 | b <- select_if(mtcars, is.character) 217 | #> select_if: dropped all variables 218 | c <- relocate(mtcars, hp) 219 | #> relocate: columns reordered (hp, mpg, cyl, disp, drat, …) 220 | d <- select(mtcars, a = wt, b = mpg) 221 | #> select: renamed 2 variables (a, b) and dropped 9 variables 222 | 223 | e <- rename(mtcars, miles_per_gallon = mpg) 224 | #> rename: renamed one variable (miles_per_gallon) 225 | f <- rename_with(mtcars, toupper) 226 | #> rename_with: renamed 11 variables (MPG, CYL, DISP, HP, DRAT, …) 227 | ``` 228 | 229 | ### summarize 230 | 231 | ``` r 232 | a <- mtcars %>% 233 | group_by(cyl, carb) %>% 234 | summarize(total_weight = sum(wt)) 235 | #> group_by: 2 grouping variables (cyl, carb) 236 | #> summarize: now 9 rows and 3 columns, one group variable remaining (cyl) 237 | 238 | b <- iris %>% 239 | group_by(Species) %>% 240 | summarize_all(list(min, max)) 241 | #> group_by: one grouping variable (Species) 242 | #> summarize_all: now 3 rows and 9 columns, ungrouped 243 | ``` 244 | 245 | ### tally, count, add_tally, add_count 246 | 247 | ``` r 248 | a <- mtcars %>% group_by(gear, carb) %>% tally 249 | #> group_by: 2 grouping variables (gear, carb) 250 | #> tally: now 11 rows and 3 columns, one group variable remaining (gear) 251 | b <- mtcars %>% group_by(gear, carb) %>% add_tally() 252 | #> group_by: 2 grouping variables (gear, carb) 253 | #> add_tally (grouped): new variable 'n' (integer) with 5 unique values and 0% NA 254 | 255 | c <- mtcars %>% count(gear, carb) 256 | #> count: now 11 rows and 3 columns, ungrouped 257 | d <- mtcars %>% add_count(gear, carb, name = "count") 258 | #> add_count: new variable 'count' (integer) with 5 unique values and 0% NA 259 | ``` 260 | 261 | ### pivot_longer, pivot_wider 262 | 263 | ``` r 264 | longer <- mtcars %>% 265 | mutate(id = 1:n()) %>% 266 | pivot_longer(-id, names_to = "var", values_to = "value") 267 | #> mutate: new variable 'id' (integer) with 32 unique values and 0% NA 268 | #> pivot_longer: reorganized (mpg, cyl, disp, hp, drat, …) into (var, value) [was 32x12, now 352x3] 269 | wider <- longer %>% 270 | pivot_wider(names_from = var, values_from = value) 271 | #> pivot_wider: reorganized (var, value) into (mpg, cyl, disp, hp, drat, …) [was 272 | #> 352x3, now 32x12] 273 | ``` 274 | 275 | Tidylog also supports `gather` and `spread`. 276 | 277 | ## Turning logging off, registering additional loggers 278 | 279 | To turn off the output for just a particular function call, you can 280 | simply call the dplyr and tidyr functions directly, e.g. `dplyr::filter` 281 | or `tidyr::drop_na`. 282 | 283 | To turn off the output more permanently, set the global option 284 | `tidylog.display` to an empty list: 285 | 286 | ``` r 287 | options("tidylog.display" = list()) # turn off 288 | a <- filter(mtcars, mpg > 20) 289 | 290 | options("tidylog.display" = NULL) # turn on 291 | a <- filter(mtcars, mpg > 20) 292 | #> filter: removed 18 rows (56%), 14 rows remaining 293 | ``` 294 | 295 | This option can also be used to register additional loggers. The option 296 | `tidylog.display` expects a list of functions. By default (when 297 | `tidylog.display` is set to NULL), tidylog will use the `message` 298 | function to display the output, but if you prefer a more colorful 299 | output, simply overwrite the option: 300 | 301 | ``` r 302 | library("crayon") # for terminal colors 303 | crayon <- function(x) cat(red$bold(x), sep = "\n") 304 | options("tidylog.display" = list(crayon)) 305 | a <- filter(mtcars, mpg > 20) 306 | #> filter: removed 18 rows (56%), 14 rows remaining 307 | ``` 308 | 309 | To print the output both to the screen and to a file, you could use: 310 | 311 | ``` r 312 | log_to_file <- function(text) cat(text, file = "log.txt", sep = "\n", append = TRUE) 313 | options("tidylog.display" = list(message, log_to_file)) 314 | a <- filter(mtcars, mpg > 20) 315 | #> filter: removed 18 rows (56%), 14 rows remaining 316 | ``` 317 | 318 | ## Namespace conflicts 319 | 320 | Tidylog redefines several of the functions exported by dplyr and tidyr, 321 | so it should be loaded last, otherwise there will be no output. A more 322 | explicit way to resolve namespace conflicts is to use the 323 | [conflicted](https://CRAN.R-project.org/package=conflicted) package: 324 | 325 | ``` r 326 | library("dplyr") 327 | library("tidyr") 328 | library("tidylog") 329 | library("conflicted") 330 | for (f in getNamespaceExports("tidylog")) { 331 | conflicted::conflict_prefer(f, "tidylog", quiet = TRUE) 332 | } 333 | ``` 334 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | patch: 10 | default: 11 | target: auto 12 | threshold: 1% 13 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | This is a resubmission. One NOTE has been fixed. 2 | 3 | ## Test environments 4 | 5 | * local OS X, R 4.2.0 6 | * CRAN win-builder: R-devel 7 | * GitHub Actions: macos, win, linux 8 | 9 | ## R CMD check results 10 | 11 | No ERRORs, WARNINGSs or NOTES. 12 | -------------------------------------------------------------------------------- /generate_docs.R: -------------------------------------------------------------------------------- 1 | unlink("man", recursive = TRUE) 2 | devtools::document(roclets = c('rd', 'collate', 'namespace')) 3 | 4 | library(glue) 5 | library(tidylog) 6 | library(dplyr) 7 | library(tidyr) 8 | library(stringr) 9 | 10 | # get tidylog functions (not very elegant...) 11 | conn <- file("NAMESPACE") 12 | namespace <- readLines(conn) 13 | close(conn) 14 | functions <- namespace[grepl("export", namespace)] 15 | functions <- sub("export\\(", "", functions) 16 | functions <- sub("\\)", "", functions) 17 | 18 | functions_dplyr <- lsf.str("package:dplyr") 19 | functions_tidyr <- lsf.str("package:tidyr") 20 | 21 | template <- "\\name{} 22 | \\alias{} 23 | \\title{Wrapper around :: 24 | that prints information about the operation} 25 | \\usage{ 26 | 27 | } 28 | \\arguments{ 29 | 30 | } 31 | \\value{ 32 | see \\link[]{} 33 | } 34 | \\description{ 35 | Wrapper around :: 36 | that prints information about the operation 37 | }" 38 | 39 | tidylog_env <- environment(tidylog::tidylog) 40 | html_links <- tools::findHTMLlinks(level = 0:5) 41 | 42 | for (f in functions) { 43 | if (f %in% functions_dplyr) { 44 | package <- "dplyr" 45 | } else if (f %in% functions_tidyr) { 46 | package <- "tidyr" 47 | } else { 48 | next 49 | } 50 | # find topic 51 | topic <- html_links[str_detect(html_links, package) & names(html_links) == f] 52 | topic <- str_match(topic, "/([^/]*)\\.html")[, 2] 53 | if (length(topic) == 0) { 54 | topic <- "" 55 | } else { 56 | topic <- paste0(":", topic) 57 | } 58 | 59 | args_list <- names(formals(f, tidylog_env)) 60 | usage <- glue("{f}({paste(args_list, collapse = ', ')})") 61 | args <- glue("\\item{}{see \\link[]{}}", .open = "<", .close = ">") 62 | args <- paste0(args, collapse = "\n\n") 63 | 64 | doc <- glue(template, .open = "<", .close = ">") 65 | conn <- file(glue("man/{f}.Rd")) 66 | writeLines(doc, conn) 67 | close(conn) 68 | } 69 | -------------------------------------------------------------------------------- /man/add_count.Rd: -------------------------------------------------------------------------------- 1 | \name{add_count} 2 | \alias{add_count} 3 | \title{Wrapper around dplyr::add_count 4 | that prints information about the operation} 5 | \usage{ 6 | add_count(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:count]{add_count}} 10 | 11 | \item{...}{see \link[dplyr:count]{add_count}} 12 | } 13 | \value{ 14 | see \link[dplyr:count]{add_count} 15 | } 16 | \description{ 17 | Wrapper around dplyr::add_count 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/add_tally.Rd: -------------------------------------------------------------------------------- 1 | \name{add_tally} 2 | \alias{add_tally} 3 | \title{Wrapper around dplyr::add_tally 4 | that prints information about the operation} 5 | \usage{ 6 | add_tally(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:count]{add_tally}} 10 | 11 | \item{...}{see \link[dplyr:count]{add_tally}} 12 | } 13 | \value{ 14 | see \link[dplyr:count]{add_tally} 15 | } 16 | \description{ 17 | Wrapper around dplyr::add_tally 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/anti_join.Rd: -------------------------------------------------------------------------------- 1 | \name{anti_join} 2 | \alias{anti_join} 3 | \title{Wrapper around dplyr::anti_join 4 | that prints information about the operation} 5 | \usage{ 6 | anti_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:filter-joins]{anti_join}} 10 | 11 | \item{y}{see \link[dplyr:filter-joins]{anti_join}} 12 | 13 | \item{by}{see \link[dplyr:filter-joins]{anti_join}} 14 | 15 | \item{...}{see \link[dplyr:filter-joins]{anti_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:filter-joins]{anti_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::anti_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/count.Rd: -------------------------------------------------------------------------------- 1 | \name{count} 2 | \alias{count} 3 | \title{Wrapper around dplyr::count 4 | that prints information about the operation} 5 | \usage{ 6 | count(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:count]{count}} 10 | 11 | \item{...}{see \link[dplyr:count]{count}} 12 | } 13 | \value{ 14 | see \link[dplyr:count]{count} 15 | } 16 | \description{ 17 | Wrapper around dplyr::count 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/distinct.Rd: -------------------------------------------------------------------------------- 1 | \name{distinct} 2 | \alias{distinct} 3 | \title{Wrapper around dplyr::distinct 4 | that prints information about the operation} 5 | \usage{ 6 | distinct(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:distinct]{distinct}} 10 | 11 | \item{...}{see \link[dplyr:distinct]{distinct}} 12 | } 13 | \value{ 14 | see \link[dplyr:distinct]{distinct} 15 | } 16 | \description{ 17 | Wrapper around dplyr::distinct 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/distinct_all.Rd: -------------------------------------------------------------------------------- 1 | \name{distinct_all} 2 | \alias{distinct_all} 3 | \title{Wrapper around dplyr::distinct_all 4 | that prints information about the operation} 5 | \usage{ 6 | distinct_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:distinct_all]{distinct_all}} 10 | 11 | \item{...}{see \link[dplyr:distinct_all]{distinct_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:distinct_all]{distinct_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::distinct_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/distinct_at.Rd: -------------------------------------------------------------------------------- 1 | \name{distinct_at} 2 | \alias{distinct_at} 3 | \title{Wrapper around dplyr::distinct_at 4 | that prints information about the operation} 5 | \usage{ 6 | distinct_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:distinct_all]{distinct_at}} 10 | 11 | \item{...}{see \link[dplyr:distinct_all]{distinct_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:distinct_all]{distinct_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::distinct_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/distinct_if.Rd: -------------------------------------------------------------------------------- 1 | \name{distinct_if} 2 | \alias{distinct_if} 3 | \title{Wrapper around dplyr::distinct_if 4 | that prints information about the operation} 5 | \usage{ 6 | distinct_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:distinct_all]{distinct_if}} 10 | 11 | \item{...}{see \link[dplyr:distinct_all]{distinct_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:distinct_all]{distinct_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::distinct_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/drop_na.Rd: -------------------------------------------------------------------------------- 1 | \name{drop_na} 2 | \alias{drop_na} 3 | \title{Wrapper around tidyr::drop_na 4 | that prints information about the operation} 5 | \usage{ 6 | drop_na(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:drop_na]{drop_na}} 10 | 11 | \item{...}{see \link[tidyr:drop_na]{drop_na}} 12 | } 13 | \value{ 14 | see \link[tidyr:drop_na]{drop_na} 15 | } 16 | \description{ 17 | Wrapper around tidyr::drop_na 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/fill.Rd: -------------------------------------------------------------------------------- 1 | \name{fill} 2 | \alias{fill} 3 | \title{Wrapper around tidyr::fill 4 | that prints information about the operation} 5 | \usage{ 6 | fill(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:fill]{fill}} 10 | 11 | \item{...}{see \link[tidyr:fill]{fill}} 12 | } 13 | \value{ 14 | see \link[tidyr:fill]{fill} 15 | } 16 | \description{ 17 | Wrapper around tidyr::fill 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/filter.Rd: -------------------------------------------------------------------------------- 1 | \name{filter} 2 | \alias{filter} 3 | \title{Wrapper around dplyr::filter 4 | that prints information about the operation} 5 | \usage{ 6 | filter(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr]{filter}} 10 | 11 | \item{...}{see \link[dplyr]{filter}} 12 | } 13 | \value{ 14 | see \link[dplyr]{filter} 15 | } 16 | \description{ 17 | Wrapper around dplyr::filter 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/filter_all.Rd: -------------------------------------------------------------------------------- 1 | \name{filter_all} 2 | \alias{filter_all} 3 | \title{Wrapper around dplyr::filter_all 4 | that prints information about the operation} 5 | \usage{ 6 | filter_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:filter_all]{filter_all}} 10 | 11 | \item{...}{see \link[dplyr:filter_all]{filter_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:filter_all]{filter_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::filter_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/filter_at.Rd: -------------------------------------------------------------------------------- 1 | \name{filter_at} 2 | \alias{filter_at} 3 | \title{Wrapper around dplyr::filter_at 4 | that prints information about the operation} 5 | \usage{ 6 | filter_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:filter_all]{filter_at}} 10 | 11 | \item{...}{see \link[dplyr:filter_all]{filter_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:filter_all]{filter_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::filter_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/filter_if.Rd: -------------------------------------------------------------------------------- 1 | \name{filter_if} 2 | \alias{filter_if} 3 | \title{Wrapper around dplyr::filter_if 4 | that prints information about the operation} 5 | \usage{ 6 | filter_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:filter_all]{filter_if}} 10 | 11 | \item{...}{see \link[dplyr:filter_all]{filter_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:filter_all]{filter_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::filter_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/full_join.Rd: -------------------------------------------------------------------------------- 1 | \name{full_join} 2 | \alias{full_join} 3 | \title{Wrapper around dplyr::full_join 4 | that prints information about the operation} 5 | \usage{ 6 | full_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:mutate-joins]{full_join}} 10 | 11 | \item{y}{see \link[dplyr:mutate-joins]{full_join}} 12 | 13 | \item{by}{see \link[dplyr:mutate-joins]{full_join}} 14 | 15 | \item{...}{see \link[dplyr:mutate-joins]{full_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:mutate-joins]{full_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::full_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/gather.Rd: -------------------------------------------------------------------------------- 1 | \name{gather} 2 | \alias{gather} 3 | \title{Wrapper around tidyr::gather 4 | that prints information about the operation} 5 | \usage{ 6 | gather(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:gather]{gather}} 10 | 11 | \item{...}{see \link[tidyr:gather]{gather}} 12 | } 13 | \value{ 14 | see \link[tidyr:gather]{gather} 15 | } 16 | \description{ 17 | Wrapper around tidyr::gather 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/group_by.Rd: -------------------------------------------------------------------------------- 1 | \name{group_by} 2 | \alias{group_by} 3 | \title{Wrapper around dplyr::group_by 4 | that prints information about the operation} 5 | \usage{ 6 | group_by(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:group_by]{group_by}} 10 | 11 | \item{...}{see \link[dplyr:group_by]{group_by}} 12 | } 13 | \value{ 14 | see \link[dplyr:group_by]{group_by} 15 | } 16 | \description{ 17 | Wrapper around dplyr::group_by 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/group_by_all.Rd: -------------------------------------------------------------------------------- 1 | \name{group_by_all} 2 | \alias{group_by_all} 3 | \title{Wrapper around dplyr::group_by_all 4 | that prints information about the operation} 5 | \usage{ 6 | group_by_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:group_by_all]{group_by_all}} 10 | 11 | \item{...}{see \link[dplyr:group_by_all]{group_by_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:group_by_all]{group_by_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::group_by_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/group_by_at.Rd: -------------------------------------------------------------------------------- 1 | \name{group_by_at} 2 | \alias{group_by_at} 3 | \title{Wrapper around dplyr::group_by_at 4 | that prints information about the operation} 5 | \usage{ 6 | group_by_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:group_by_all]{group_by_at}} 10 | 11 | \item{...}{see \link[dplyr:group_by_all]{group_by_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:group_by_all]{group_by_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::group_by_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/group_by_if.Rd: -------------------------------------------------------------------------------- 1 | \name{group_by_if} 2 | \alias{group_by_if} 3 | \title{Wrapper around dplyr::group_by_if 4 | that prints information about the operation} 5 | \usage{ 6 | group_by_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:group_by_all]{group_by_if}} 10 | 11 | \item{...}{see \link[dplyr:group_by_all]{group_by_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:group_by_all]{group_by_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::group_by_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/inner_join.Rd: -------------------------------------------------------------------------------- 1 | \name{inner_join} 2 | \alias{inner_join} 3 | \title{Wrapper around dplyr::inner_join 4 | that prints information about the operation} 5 | \usage{ 6 | inner_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:mutate-joins]{inner_join}} 10 | 11 | \item{y}{see \link[dplyr:mutate-joins]{inner_join}} 12 | 13 | \item{by}{see \link[dplyr:mutate-joins]{inner_join}} 14 | 15 | \item{...}{see \link[dplyr:mutate-joins]{inner_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:mutate-joins]{inner_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::inner_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/left_join.Rd: -------------------------------------------------------------------------------- 1 | \name{left_join} 2 | \alias{left_join} 3 | \title{Wrapper around dplyr::left_join 4 | that prints information about the operation} 5 | \usage{ 6 | left_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:mutate-joins]{left_join}} 10 | 11 | \item{y}{see \link[dplyr:mutate-joins]{left_join}} 12 | 13 | \item{by}{see \link[dplyr:mutate-joins]{left_join}} 14 | 15 | \item{...}{see \link[dplyr:mutate-joins]{left_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:mutate-joins]{left_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::left_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/mutate.Rd: -------------------------------------------------------------------------------- 1 | \name{mutate} 2 | \alias{mutate} 3 | \title{Wrapper around dplyr::mutate 4 | that prints information about the operation} 5 | \usage{ 6 | mutate(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:mutate]{mutate}} 10 | 11 | \item{...}{see \link[dplyr:mutate]{mutate}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate]{mutate} 15 | } 16 | \description{ 17 | Wrapper around dplyr::mutate 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/mutate_all.Rd: -------------------------------------------------------------------------------- 1 | \name{mutate_all} 2 | \alias{mutate_all} 3 | \title{Wrapper around dplyr::mutate_all 4 | that prints information about the operation} 5 | \usage{ 6 | mutate_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{mutate_all}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{mutate_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{mutate_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::mutate_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/mutate_at.Rd: -------------------------------------------------------------------------------- 1 | \name{mutate_at} 2 | \alias{mutate_at} 3 | \title{Wrapper around dplyr::mutate_at 4 | that prints information about the operation} 5 | \usage{ 6 | mutate_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{mutate_at}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{mutate_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{mutate_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::mutate_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/mutate_if.Rd: -------------------------------------------------------------------------------- 1 | \name{mutate_if} 2 | \alias{mutate_if} 3 | \title{Wrapper around dplyr::mutate_if 4 | that prints information about the operation} 5 | \usage{ 6 | mutate_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{mutate_if}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{mutate_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{mutate_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::mutate_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/pivot_longer.Rd: -------------------------------------------------------------------------------- 1 | \name{pivot_longer} 2 | \alias{pivot_longer} 3 | \title{Wrapper around tidyr::pivot_longer 4 | that prints information about the operation} 5 | \usage{ 6 | pivot_longer(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:pivot_longer]{pivot_longer}} 10 | 11 | \item{...}{see \link[tidyr:pivot_longer]{pivot_longer}} 12 | } 13 | \value{ 14 | see \link[tidyr:pivot_longer]{pivot_longer} 15 | } 16 | \description{ 17 | Wrapper around tidyr::pivot_longer 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/pivot_wider.Rd: -------------------------------------------------------------------------------- 1 | \name{pivot_wider} 2 | \alias{pivot_wider} 3 | \title{Wrapper around tidyr::pivot_wider 4 | that prints information about the operation} 5 | \usage{ 6 | pivot_wider(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:pivot_wider]{pivot_wider}} 10 | 11 | \item{...}{see \link[tidyr:pivot_wider]{pivot_wider}} 12 | } 13 | \value{ 14 | see \link[tidyr:pivot_wider]{pivot_wider} 15 | } 16 | \description{ 17 | Wrapper around tidyr::pivot_wider 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/relocate.Rd: -------------------------------------------------------------------------------- 1 | \name{relocate} 2 | \alias{relocate} 3 | \title{Wrapper around dplyr::relocate 4 | that prints information about the operation} 5 | \usage{ 6 | relocate(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:relocate]{relocate}} 10 | 11 | \item{...}{see \link[dplyr:relocate]{relocate}} 12 | } 13 | \value{ 14 | see \link[dplyr:relocate]{relocate} 15 | } 16 | \description{ 17 | Wrapper around dplyr::relocate 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/rename.Rd: -------------------------------------------------------------------------------- 1 | \name{rename} 2 | \alias{rename} 3 | \title{Wrapper around dplyr::rename 4 | that prints information about the operation} 5 | \usage{ 6 | rename(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:rename]{rename}} 10 | 11 | \item{...}{see \link[dplyr:rename]{rename}} 12 | } 13 | \value{ 14 | see \link[dplyr:rename]{rename} 15 | } 16 | \description{ 17 | Wrapper around dplyr::rename 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/rename_all.Rd: -------------------------------------------------------------------------------- 1 | \name{rename_all} 2 | \alias{rename_all} 3 | \title{Wrapper around dplyr::rename_all 4 | that prints information about the operation} 5 | \usage{ 6 | rename_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{rename_all}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{rename_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{rename_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::rename_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/rename_at.Rd: -------------------------------------------------------------------------------- 1 | \name{rename_at} 2 | \alias{rename_at} 3 | \title{Wrapper around dplyr::rename_at 4 | that prints information about the operation} 5 | \usage{ 6 | rename_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{rename_at}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{rename_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{rename_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::rename_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/rename_if.Rd: -------------------------------------------------------------------------------- 1 | \name{rename_if} 2 | \alias{rename_if} 3 | \title{Wrapper around dplyr::rename_if 4 | that prints information about the operation} 5 | \usage{ 6 | rename_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{rename_if}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{rename_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{rename_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::rename_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/rename_with.Rd: -------------------------------------------------------------------------------- 1 | \name{rename_with} 2 | \alias{rename_with} 3 | \title{Wrapper around dplyr::rename_with 4 | that prints information about the operation} 5 | \usage{ 6 | rename_with(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:rename]{rename_with}} 10 | 11 | \item{...}{see \link[dplyr:rename]{rename_with}} 12 | } 13 | \value{ 14 | see \link[dplyr:rename]{rename_with} 15 | } 16 | \description{ 17 | Wrapper around dplyr::rename_with 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/replace_na.Rd: -------------------------------------------------------------------------------- 1 | \name{replace_na} 2 | \alias{replace_na} 3 | \title{Wrapper around tidyr::replace_na 4 | that prints information about the operation} 5 | \usage{ 6 | replace_na(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:replace_na]{replace_na}} 10 | 11 | \item{...}{see \link[tidyr:replace_na]{replace_na}} 12 | } 13 | \value{ 14 | see \link[tidyr:replace_na]{replace_na} 15 | } 16 | \description{ 17 | Wrapper around tidyr::replace_na 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/right_join.Rd: -------------------------------------------------------------------------------- 1 | \name{right_join} 2 | \alias{right_join} 3 | \title{Wrapper around dplyr::right_join 4 | that prints information about the operation} 5 | \usage{ 6 | right_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:mutate-joins]{right_join}} 10 | 11 | \item{y}{see \link[dplyr:mutate-joins]{right_join}} 12 | 13 | \item{by}{see \link[dplyr:mutate-joins]{right_join}} 14 | 15 | \item{...}{see \link[dplyr:mutate-joins]{right_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:mutate-joins]{right_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::right_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/sample_frac.Rd: -------------------------------------------------------------------------------- 1 | \name{sample_frac} 2 | \alias{sample_frac} 3 | \title{Wrapper around dplyr::sample_frac 4 | that prints information about the operation} 5 | \usage{ 6 | sample_frac(tbl, ...) 7 | } 8 | \arguments{ 9 | \item{tbl}{see \link[dplyr:sample_n]{sample_frac}} 10 | 11 | \item{...}{see \link[dplyr:sample_n]{sample_frac}} 12 | } 13 | \value{ 14 | see \link[dplyr:sample_n]{sample_frac} 15 | } 16 | \description{ 17 | Wrapper around dplyr::sample_frac 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/sample_n.Rd: -------------------------------------------------------------------------------- 1 | \name{sample_n} 2 | \alias{sample_n} 3 | \title{Wrapper around dplyr::sample_n 4 | that prints information about the operation} 5 | \usage{ 6 | sample_n(tbl, ...) 7 | } 8 | \arguments{ 9 | \item{tbl}{see \link[dplyr:sample_n]{sample_n}} 10 | 11 | \item{...}{see \link[dplyr:sample_n]{sample_n}} 12 | } 13 | \value{ 14 | see \link[dplyr:sample_n]{sample_n} 15 | } 16 | \description{ 17 | Wrapper around dplyr::sample_n 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/select.Rd: -------------------------------------------------------------------------------- 1 | \name{select} 2 | \alias{select} 3 | \title{Wrapper around dplyr::select 4 | that prints information about the operation} 5 | \usage{ 6 | select(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr]{select}} 10 | 11 | \item{...}{see \link[dplyr]{select}} 12 | } 13 | \value{ 14 | see \link[dplyr]{select} 15 | } 16 | \description{ 17 | Wrapper around dplyr::select 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/select_all.Rd: -------------------------------------------------------------------------------- 1 | \name{select_all} 2 | \alias{select_all} 3 | \title{Wrapper around dplyr::select_all 4 | that prints information about the operation} 5 | \usage{ 6 | select_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{select_all}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{select_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{select_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::select_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/select_at.Rd: -------------------------------------------------------------------------------- 1 | \name{select_at} 2 | \alias{select_at} 3 | \title{Wrapper around dplyr::select_at 4 | that prints information about the operation} 5 | \usage{ 6 | select_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{select_at}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{select_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{select_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::select_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/select_if.Rd: -------------------------------------------------------------------------------- 1 | \name{select_if} 2 | \alias{select_if} 3 | \title{Wrapper around dplyr::select_if 4 | that prints information about the operation} 5 | \usage{ 6 | select_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:select_all]{select_if}} 10 | 11 | \item{...}{see \link[dplyr:select_all]{select_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:select_all]{select_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::select_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/semi_join.Rd: -------------------------------------------------------------------------------- 1 | \name{semi_join} 2 | \alias{semi_join} 3 | \title{Wrapper around dplyr::semi_join 4 | that prints information about the operation} 5 | \usage{ 6 | semi_join(x, y, by, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:filter-joins]{semi_join}} 10 | 11 | \item{y}{see \link[dplyr:filter-joins]{semi_join}} 12 | 13 | \item{by}{see \link[dplyr:filter-joins]{semi_join}} 14 | 15 | \item{...}{see \link[dplyr:filter-joins]{semi_join}} 16 | } 17 | \value{ 18 | see \link[dplyr:filter-joins]{semi_join} 19 | } 20 | \description{ 21 | Wrapper around dplyr::semi_join 22 | that prints information about the operation 23 | } 24 | -------------------------------------------------------------------------------- /man/separate_wider_delim.Rd: -------------------------------------------------------------------------------- 1 | \name{separate_wider_delim} 2 | \alias{separate_wider_delim} 3 | \title{Wrapper around tidyr::separate_wider_delim 4 | that prints information about the operation} 5 | \usage{ 6 | separate_wider_delim(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:separate_wider_delim]{separate_wider_delim}} 10 | 11 | \item{...}{see \link[tidyr:separate_wider_delim]{separate_wider_delim}} 12 | } 13 | \value{ 14 | see \link[tidyr:separate_wider_delim]{separate_wider_delim} 15 | } 16 | \description{ 17 | Wrapper around tidyr::separate_wider_delim 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/separate_wider_position.Rd: -------------------------------------------------------------------------------- 1 | \name{separate_wider_position} 2 | \alias{separate_wider_position} 3 | \title{Wrapper around tidyr::separate_wider_position 4 | that prints information about the operation} 5 | \usage{ 6 | separate_wider_position(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:separate_wider_delim]{separate_wider_position}} 10 | 11 | \item{...}{see \link[tidyr:separate_wider_delim]{separate_wider_position}} 12 | } 13 | \value{ 14 | see \link[tidyr:separate_wider_delim]{separate_wider_position} 15 | } 16 | \description{ 17 | Wrapper around tidyr::separate_wider_position 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/separate_wider_regex.Rd: -------------------------------------------------------------------------------- 1 | \name{separate_wider_regex} 2 | \alias{separate_wider_regex} 3 | \title{Wrapper around tidyr::separate_wider_regex 4 | that prints information about the operation} 5 | \usage{ 6 | separate_wider_regex(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:separate_wider_delim]{separate_wider_regex}} 10 | 11 | \item{...}{see \link[tidyr:separate_wider_delim]{separate_wider_regex}} 12 | } 13 | \value{ 14 | see \link[tidyr:separate_wider_delim]{separate_wider_regex} 15 | } 16 | \description{ 17 | Wrapper around tidyr::separate_wider_regex 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice.Rd: -------------------------------------------------------------------------------- 1 | \name{slice} 2 | \alias{slice} 3 | \title{Wrapper around dplyr::slice 4 | that prints information about the operation} 5 | \usage{ 6 | slice(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice_head.Rd: -------------------------------------------------------------------------------- 1 | \name{slice_head} 2 | \alias{slice_head} 3 | \title{Wrapper around dplyr::slice_head 4 | that prints information about the operation} 5 | \usage{ 6 | slice_head(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice_head}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice_head}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice_head} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice_head 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice_max.Rd: -------------------------------------------------------------------------------- 1 | \name{slice_max} 2 | \alias{slice_max} 3 | \title{Wrapper around dplyr::slice_max 4 | that prints information about the operation} 5 | \usage{ 6 | slice_max(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice_max}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice_max}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice_max} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice_max 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice_min.Rd: -------------------------------------------------------------------------------- 1 | \name{slice_min} 2 | \alias{slice_min} 3 | \title{Wrapper around dplyr::slice_min 4 | that prints information about the operation} 5 | \usage{ 6 | slice_min(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice_min}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice_min}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice_min} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice_min 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice_sample.Rd: -------------------------------------------------------------------------------- 1 | \name{slice_sample} 2 | \alias{slice_sample} 3 | \title{Wrapper around dplyr::slice_sample 4 | that prints information about the operation} 5 | \usage{ 6 | slice_sample(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice_sample}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice_sample}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice_sample} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice_sample 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/slice_tail.Rd: -------------------------------------------------------------------------------- 1 | \name{slice_tail} 2 | \alias{slice_tail} 3 | \title{Wrapper around dplyr::slice_tail 4 | that prints information about the operation} 5 | \usage{ 6 | slice_tail(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:slice]{slice_tail}} 10 | 11 | \item{...}{see \link[dplyr:slice]{slice_tail}} 12 | } 13 | \value{ 14 | see \link[dplyr:slice]{slice_tail} 15 | } 16 | \description{ 17 | Wrapper around dplyr::slice_tail 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/spread.Rd: -------------------------------------------------------------------------------- 1 | \name{spread} 2 | \alias{spread} 3 | \title{Wrapper around tidyr::spread 4 | that prints information about the operation} 5 | \usage{ 6 | spread(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:spread]{spread}} 10 | 11 | \item{...}{see \link[tidyr:spread]{spread}} 12 | } 13 | \value{ 14 | see \link[tidyr:spread]{spread} 15 | } 16 | \description{ 17 | Wrapper around tidyr::spread 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarise.Rd: -------------------------------------------------------------------------------- 1 | \name{summarise} 2 | \alias{summarise} 3 | \title{Wrapper around dplyr::summarise 4 | that prints information about the operation} 5 | \usage{ 6 | summarise(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:summarise]{summarise}} 10 | 11 | \item{...}{see \link[dplyr:summarise]{summarise}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise]{summarise} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarise 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarise_all.Rd: -------------------------------------------------------------------------------- 1 | \name{summarise_all} 2 | \alias{summarise_all} 3 | \title{Wrapper around dplyr::summarise_all 4 | that prints information about the operation} 5 | \usage{ 6 | summarise_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarise_all}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarise_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarise_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarise_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarise_at.Rd: -------------------------------------------------------------------------------- 1 | \name{summarise_at} 2 | \alias{summarise_at} 3 | \title{Wrapper around dplyr::summarise_at 4 | that prints information about the operation} 5 | \usage{ 6 | summarise_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarise_at}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarise_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarise_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarise_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarise_if.Rd: -------------------------------------------------------------------------------- 1 | \name{summarise_if} 2 | \alias{summarise_if} 3 | \title{Wrapper around dplyr::summarise_if 4 | that prints information about the operation} 5 | \usage{ 6 | summarise_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarise_if}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarise_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarise_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarise_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarize.Rd: -------------------------------------------------------------------------------- 1 | \name{summarize} 2 | \alias{summarize} 3 | \title{Wrapper around dplyr::summarize 4 | that prints information about the operation} 5 | \usage{ 6 | summarize(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:summarise]{summarize}} 10 | 11 | \item{...}{see \link[dplyr:summarise]{summarize}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise]{summarize} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarize 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarize_all.Rd: -------------------------------------------------------------------------------- 1 | \name{summarize_all} 2 | \alias{summarize_all} 3 | \title{Wrapper around dplyr::summarize_all 4 | that prints information about the operation} 5 | \usage{ 6 | summarize_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarize_all}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarize_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarize_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarize_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarize_at.Rd: -------------------------------------------------------------------------------- 1 | \name{summarize_at} 2 | \alias{summarize_at} 3 | \title{Wrapper around dplyr::summarize_at 4 | that prints information about the operation} 5 | \usage{ 6 | summarize_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarize_at}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarize_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarize_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarize_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/summarize_if.Rd: -------------------------------------------------------------------------------- 1 | \name{summarize_if} 2 | \alias{summarize_if} 3 | \title{Wrapper around dplyr::summarize_if 4 | that prints information about the operation} 5 | \usage{ 6 | summarize_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:summarise_all]{summarize_if}} 10 | 11 | \item{...}{see \link[dplyr:summarise_all]{summarize_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:summarise_all]{summarize_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::summarize_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/tally.Rd: -------------------------------------------------------------------------------- 1 | \name{tally} 2 | \alias{tally} 3 | \title{Wrapper around dplyr::tally 4 | that prints information about the operation} 5 | \usage{ 6 | tally(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:count]{tally}} 10 | 11 | \item{...}{see \link[dplyr:count]{tally}} 12 | } 13 | \value{ 14 | see \link[dplyr:count]{tally} 15 | } 16 | \description{ 17 | Wrapper around dplyr::tally 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/tidylog.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tidylog.R 3 | \name{tidylog} 4 | \alias{tidylog} 5 | \title{outputs some information about the data frame/tbl} 6 | \usage{ 7 | tidylog(.data) 8 | } 9 | \arguments{ 10 | \item{.data}{a tbl/data frame} 11 | } 12 | \value{ 13 | same as .data 14 | } 15 | \description{ 16 | outputs some information about the data frame/tbl 17 | } 18 | \examples{ 19 | tidylog(mtcars) 20 | #> tidylog: data.frame with 32 rows and 11 columns 21 | } 22 | -------------------------------------------------------------------------------- /man/top_frac.Rd: -------------------------------------------------------------------------------- 1 | \name{top_frac} 2 | \alias{top_frac} 3 | \title{Wrapper around dplyr::top_frac 4 | that prints information about the operation} 5 | \usage{ 6 | top_frac(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:top_n]{top_frac}} 10 | 11 | \item{...}{see \link[dplyr:top_n]{top_frac}} 12 | } 13 | \value{ 14 | see \link[dplyr:top_n]{top_frac} 15 | } 16 | \description{ 17 | Wrapper around dplyr::top_frac 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/top_n.Rd: -------------------------------------------------------------------------------- 1 | \name{top_n} 2 | \alias{top_n} 3 | \title{Wrapper around dplyr::top_n 4 | that prints information about the operation} 5 | \usage{ 6 | top_n(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:top_n]{top_n}} 10 | 11 | \item{...}{see \link[dplyr:top_n]{top_n}} 12 | } 13 | \value{ 14 | see \link[dplyr:top_n]{top_n} 15 | } 16 | \description{ 17 | Wrapper around dplyr::top_n 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/transmute.Rd: -------------------------------------------------------------------------------- 1 | \name{transmute} 2 | \alias{transmute} 3 | \title{Wrapper around dplyr::transmute 4 | that prints information about the operation} 5 | \usage{ 6 | transmute(.data, ...) 7 | } 8 | \arguments{ 9 | \item{.data}{see \link[dplyr:transmute]{transmute}} 10 | 11 | \item{...}{see \link[dplyr:transmute]{transmute}} 12 | } 13 | \value{ 14 | see \link[dplyr:transmute]{transmute} 15 | } 16 | \description{ 17 | Wrapper around dplyr::transmute 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/transmute_all.Rd: -------------------------------------------------------------------------------- 1 | \name{transmute_all} 2 | \alias{transmute_all} 3 | \title{Wrapper around dplyr::transmute_all 4 | that prints information about the operation} 5 | \usage{ 6 | transmute_all(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{transmute_all}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{transmute_all}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{transmute_all} 15 | } 16 | \description{ 17 | Wrapper around dplyr::transmute_all 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/transmute_at.Rd: -------------------------------------------------------------------------------- 1 | \name{transmute_at} 2 | \alias{transmute_at} 3 | \title{Wrapper around dplyr::transmute_at 4 | that prints information about the operation} 5 | \usage{ 6 | transmute_at(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{transmute_at}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{transmute_at}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{transmute_at} 15 | } 16 | \description{ 17 | Wrapper around dplyr::transmute_at 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/transmute_if.Rd: -------------------------------------------------------------------------------- 1 | \name{transmute_if} 2 | \alias{transmute_if} 3 | \title{Wrapper around dplyr::transmute_if 4 | that prints information about the operation} 5 | \usage{ 6 | transmute_if(.tbl, ...) 7 | } 8 | \arguments{ 9 | \item{.tbl}{see \link[dplyr:mutate_all]{transmute_if}} 10 | 11 | \item{...}{see \link[dplyr:mutate_all]{transmute_if}} 12 | } 13 | \value{ 14 | see \link[dplyr:mutate_all]{transmute_if} 15 | } 16 | \description{ 17 | Wrapper around dplyr::transmute_if 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/uncount.Rd: -------------------------------------------------------------------------------- 1 | \name{uncount} 2 | \alias{uncount} 3 | \title{Wrapper around tidyr::uncount 4 | that prints information about the operation} 5 | \usage{ 6 | uncount(data, ...) 7 | } 8 | \arguments{ 9 | \item{data}{see \link[tidyr:uncount]{uncount}} 10 | 11 | \item{...}{see \link[tidyr:uncount]{uncount}} 12 | } 13 | \value{ 14 | see \link[tidyr:uncount]{uncount} 15 | } 16 | \description{ 17 | Wrapper around tidyr::uncount 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /man/ungroup.Rd: -------------------------------------------------------------------------------- 1 | \name{ungroup} 2 | \alias{ungroup} 3 | \title{Wrapper around dplyr::ungroup 4 | that prints information about the operation} 5 | \usage{ 6 | ungroup(x, ...) 7 | } 8 | \arguments{ 9 | \item{x}{see \link[dplyr:group_by]{ungroup}} 10 | 11 | \item{...}{see \link[dplyr:group_by]{ungroup}} 12 | } 13 | \value{ 14 | see \link[dplyr:group_by]{ungroup} 15 | } 16 | \description{ 17 | Wrapper around dplyr::ungroup 18 | that prints information about the operation 19 | } 20 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library("testthat") 2 | library("tidylog") 3 | 4 | test_check("tidylog") 5 | -------------------------------------------------------------------------------- /tests/testthat/test_filter.R: -------------------------------------------------------------------------------- 1 | context("test_filter") 2 | library("dplyr") 3 | library("tidyr") 4 | library("tidylog") 5 | 6 | test_that("filter", { 7 | expect_message({ 8 | out <- tidylog::filter(mtcars, mpg > 1000) 9 | }) 10 | expect_equal(nrow(out), 0) 11 | 12 | expect_message({ 13 | out <- tidylog::filter(mtcars, mpg < 1000) 14 | }) 15 | expect_equal(nrow(out), nrow(mtcars)) 16 | 17 | expect_message({ 18 | out <- tidylog::filter(mtcars, mpg == 21) 19 | }) 20 | expect_equal(nrow(out), 2) 21 | 22 | expect_silent({ 23 | out <- dplyr::filter(mtcars, mpg == 21) 24 | }) 25 | }) 26 | 27 | test_that("distinct", { 28 | expect_message({ 29 | out <- tidylog::distinct(mtcars, mpg) 30 | }) 31 | expect_equal(out, dplyr::distinct(mtcars, mpg)) 32 | }) 33 | 34 | test_that("top_n, top_frac", { 35 | expect_message({ 36 | out <- tidylog::top_n(mtcars, 3, carb) 37 | }) 38 | expect_equal(out, dplyr::top_n(mtcars, 3, carb)) 39 | 40 | expect_message({ 41 | out <- tidylog::top_frac(mtcars, .5, carb) 42 | }) 43 | expect_equal(out, dplyr::top_frac(mtcars, .5, carb)) 44 | }) 45 | 46 | test_that("sample_n, sample_frac", { 47 | expect_message({ 48 | set.seed(1) 49 | out <- tidylog::sample_n(mtcars, 3) 50 | }) 51 | set.seed(1) 52 | expect_equal(out, dplyr::sample_n(mtcars, 3)) 53 | 54 | expect_message({ 55 | set.seed(1) 56 | out <- tidylog::sample_frac(mtcars, .5) 57 | }) 58 | set.seed(1) 59 | expect_equal(out, dplyr::sample_frac(mtcars, .5)) 60 | }) 61 | 62 | test_that("filter: scoped variants", { 63 | expect_message({ 64 | out <- tidylog::filter_all(mtcars, all_vars(. > 150)) 65 | }) 66 | expect_equal(out, dplyr::filter_all(mtcars, all_vars(. > 150))) 67 | 68 | expect_message({ 69 | out <- tidylog::filter_if(mtcars, ~ all(floor(.) == .), all_vars(. != 0)) 70 | }) 71 | expect_equal(out, dplyr::filter_if(mtcars, ~ all(floor(.) == .), all_vars(. != 0))) 72 | 73 | expect_message({ 74 | out <- tidylog::filter_at(mtcars, vars(starts_with("d")), any_vars(. %% 2 == 0)) 75 | }) 76 | expect_equal(out, dplyr::filter_at(mtcars, vars(starts_with("d")), any_vars(. %% 2 == 0))) 77 | }) 78 | 79 | test_that("distinct: scoped variants", { 80 | df <- tibble(x = rep(2:5, each = 2) / 2, y = rep(2:3, each = 4) / 2) 81 | 82 | expect_message({ 83 | out <- tidylog::distinct_all(df) 84 | }) 85 | expect_equal(out, dplyr::distinct_all(df)) 86 | 87 | expect_message({ 88 | out <- tidylog::distinct_if(df, is.numeric) 89 | }) 90 | expect_equal(out, dplyr::distinct_if(df, is.numeric)) 91 | 92 | expect_message({ 93 | out <- tidylog::distinct_at(df, vars(x, y)) 94 | }) 95 | expect_equal(out, dplyr::distinct_at(df, vars(x, y))) 96 | }) 97 | 98 | test_that("filter: argument order", { 99 | expect_message({ 100 | out <- tidylog::filter(mpg == 21, .data = mtcars) 101 | }) 102 | expect_equal(nrow(out), 2) 103 | 104 | expect_message({ 105 | out <- tidylog::distinct(mpg, .data = mtcars) 106 | }) 107 | expect_equal(nrow(out), nrow(dplyr::distinct(mtcars, mpg))) 108 | }) 109 | 110 | test_that("drop_na", { 111 | expect_message({ 112 | out <- tidylog::drop_na(airquality, Ozone) 113 | }) 114 | expect_equal(nrow(out), nrow(tidyr::drop_na(airquality, Ozone))) 115 | 116 | expect_message({ 117 | out <- tidylog::drop_na(airquality, Wind, Temp, Month, Day) 118 | }) 119 | expect_equal(nrow(out), nrow(airquality)) 120 | 121 | expect_message({ 122 | out <- tidylog::drop_na(airquality) 123 | }) 124 | expect_equal(nrow(out), nrow(na.omit(airquality))) 125 | 126 | expect_message({ 127 | out <- tidylog::drop_na(airquality, Solar.R) 128 | }) 129 | expect_equal(nrow(out), 146) 130 | 131 | }) 132 | 133 | test_that("slice_*", { 134 | expect_message({ 135 | out <- tidylog::slice(mtcars, 5:n()) 136 | }) 137 | expect_equal(out, dplyr::slice(mtcars, 5:n())) 138 | 139 | expect_message({ 140 | out <- tidylog::slice_head(mtcars, n = 5) 141 | }) 142 | expect_equal(out, dplyr::slice_head(mtcars, n = 5)) 143 | 144 | expect_message({ 145 | out <- tidylog::slice_tail(mtcars, n = 3) 146 | }) 147 | expect_equal(out, dplyr::slice_tail(mtcars, n = 3)) 148 | 149 | expect_message({ 150 | out <- tidylog::slice_min(mtcars, mpg, n = 5) 151 | }) 152 | expect_equal(out, dplyr::slice_min(mtcars, mpg, n = 5)) 153 | 154 | expect_message({ 155 | out <- tidylog::slice_max(mtcars, mpg, n = 3) 156 | }) 157 | expect_equal(out, dplyr::slice_max(mtcars, mpg, n = 3)) 158 | 159 | expect_message({ 160 | set.seed(1) 161 | out <- tidylog::slice_sample(mtcars, n = 5) 162 | }) 163 | set.seed(1) 164 | expect_equal(out, dplyr::slice_sample(mtcars, n = 5)) 165 | 166 | expect_message({ 167 | set.seed(1) 168 | out <- tidylog::slice_sample(mtcars, n = 5, replace = TRUE) 169 | }) 170 | set.seed(1) 171 | expect_equal(out, dplyr::slice_sample(mtcars, n = 5, replace = TRUE) ) 172 | 173 | expect_message({ 174 | set.seed(1) 175 | out <- tidylog::slice_sample(mtcars, weight_by = wt, n = 5) 176 | }) 177 | set.seed(1) 178 | expect_equal(out, dplyr::slice_sample(mtcars, weight_by = wt, n = 5)) 179 | }) 180 | 181 | test_that("filter on grouped data", { 182 | gb <- group_by(mtcars, gear) 183 | expect_message({ 184 | out <- tidylog::filter(gb, am == 0) 185 | }, "grouped") 186 | expect_message({ 187 | out <- tidylog::filter(gb, am == 0) 188 | }, "removed one group, 2 groups remaining") 189 | }) -------------------------------------------------------------------------------- /tests/testthat/test_group_by.R: -------------------------------------------------------------------------------- 1 | context("test_group_by") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("group_by", { 6 | expect_message({ 7 | out <- tidylog::group_by(mtcars, mpg) 8 | }) 9 | expect_equal(is.grouped_df(out), TRUE) 10 | 11 | expect_silent({ 12 | out <- dplyr::group_by(mtcars, mpg) 13 | }) 14 | }) 15 | 16 | test_that("group_by: scoped variants", { 17 | expect_message({ 18 | out <- tidylog::group_by_all(mtcars) 19 | }, "11 grouping variables") # nolint 20 | 21 | expect_message({ 22 | out <- tidylog::group_by_if(mtcars, is.numeric) 23 | }, "11 grouping variables") # nolint 24 | 25 | expect_message({ 26 | out <- tidylog::group_by_at(mtcars, vars(vs:am)) 27 | }, "2 grouping variables") # nolint 28 | }) 29 | 30 | test_that("group_by: argument order", { 31 | expect_message({ 32 | out <- tidylog::group_by(mpg, .data = mtcars) 33 | }) 34 | expect_equal(is.grouped_df(out), TRUE) 35 | }) 36 | 37 | test_that("ungroup", { 38 | expect_message({ 39 | out <- tidylog::ungroup(mtcars) 40 | }) 41 | expect_equal(dplyr::is.grouped_df(out), FALSE) 42 | 43 | expect_silent({ 44 | out <- dplyr::ungroup(mtcars) 45 | }) 46 | expect_silent({ 47 | options("tidylog.display" = list()) # turn off 48 | out <- tidylog::ungroup(mtcars) 49 | }) 50 | options("tidylog.display" = NULL) # turn on 51 | }) 52 | -------------------------------------------------------------------------------- /tests/testthat/test_join.R: -------------------------------------------------------------------------------- 1 | context("test_group_by") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("join", { 6 | 7 | expect_message({ 8 | out <- tidylog::inner_join(dplyr::band_members, 9 | dplyr::band_instruments, 10 | by = "name") 11 | }) 12 | expect_equal(out, dplyr::inner_join(dplyr::band_members, 13 | dplyr::band_instruments, 14 | by = "name")) 15 | 16 | expect_message({ 17 | out <- tidylog::full_join(dplyr::band_members, 18 | dplyr::band_instruments, 19 | by = "name") 20 | }) 21 | expect_equal(out, dplyr::full_join(dplyr::band_members, 22 | dplyr::band_instruments, 23 | by = "name")) 24 | 25 | expect_message({ 26 | out <- tidylog::left_join(dplyr::band_members, 27 | dplyr::band_instruments, 28 | by = "name") 29 | }) 30 | expect_equal(out, dplyr::left_join(dplyr::band_members, 31 | dplyr::band_instruments, 32 | by = "name")) 33 | 34 | expect_message({ 35 | out <- tidylog::right_join(dplyr::band_members, 36 | dplyr::band_instruments, 37 | by = "name") 38 | }) 39 | expect_equal(out, dplyr::right_join(dplyr::band_members, 40 | dplyr::band_instruments, 41 | by = "name")) 42 | 43 | expect_message({ 44 | out <- tidylog::anti_join(dplyr::band_members, 45 | dplyr::band_instruments, 46 | by = "name") 47 | }) 48 | expect_equal(out, dplyr::anti_join(dplyr::band_members, 49 | dplyr::band_instruments, 50 | by = "name")) 51 | 52 | expect_message({ 53 | out <- tidylog::semi_join(dplyr::band_members, 54 | dplyr::band_instruments, 55 | by = "name") 56 | }) 57 | expect_equal(out, dplyr::semi_join(dplyr::band_members, 58 | dplyr::band_instruments, 59 | by = "name")) 60 | 61 | expect_silent({ 62 | out <- dplyr::inner_join(dplyr::band_members, 63 | dplyr::band_instruments, 64 | by = "name") 65 | out <- dplyr::full_join(dplyr::band_members, 66 | dplyr::band_instruments, 67 | by = "name") 68 | out <- dplyr::left_join(dplyr::band_members, 69 | dplyr::band_instruments, 70 | by = "name") 71 | out <- dplyr::right_join(dplyr::band_members, 72 | dplyr::band_instruments, 73 | by = "name") 74 | out <- dplyr::anti_join(dplyr::band_members, 75 | dplyr::band_instruments, 76 | by = "name") 77 | out <- dplyr::semi_join(dplyr::band_members, 78 | dplyr::band_instruments, 79 | by = "name") 80 | }) 81 | }) 82 | 83 | test_that("join: argument order", { 84 | expect_message({ 85 | out <- tidylog::inner_join(y = dplyr::band_instruments, 86 | x = dplyr::band_members) 87 | }) 88 | expect_equal(out, dplyr::inner_join(y = dplyr::band_instruments, 89 | x = dplyr::band_members)) 90 | expect_equal(out, dplyr::inner_join(x = dplyr::band_members, 91 | y = dplyr::band_instruments)) 92 | 93 | expect_message({ 94 | out <- tidylog::inner_join(by = "name", 95 | x = dplyr::band_members, 96 | y = dplyr::band_instruments) 97 | }) 98 | expect_equal(out, dplyr::inner_join(by = "name", 99 | x = dplyr::band_members, 100 | y = dplyr::band_instruments)) 101 | }) 102 | 103 | # adapted from dplyr tests 104 | 105 | a <- data.frame(x = c(1, 1, 2, 3), y = 1:4) 106 | b <- data.frame(x = c(1, 2, 2, 4), z = 1:4) 107 | 108 | test_that("univariate inner join has all columns, repeated matching rows", { 109 | msg <- capture_messages({ 110 | j <- tidylog::inner_join(a, b, "x", relationship = "many-to-many") 111 | }) 112 | 113 | # one row from x not included 114 | expect_match(msg, "rows only in a\\s*\\(1\\)", all = FALSE) 115 | # one row from y not included 116 | expect_match(msg, "rows only in b\\s*\\(1\\)", all = FALSE) 117 | # four rows matched, including duplicates 118 | expect_match(msg, "matched rows\\s*4", all = FALSE) 119 | expect_match(msg, "duplicate", all = FALSE) 120 | # total rows 121 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 122 | }) 123 | 124 | test_that("univariate semi join has x columns, matching rows", { 125 | msg <- capture_messages({ 126 | j <- tidylog::semi_join(a, b, "x") 127 | }) 128 | 129 | # one row from x not included 130 | expect_match(msg, "rows only in a\\s*\\(1\\)", all = FALSE) 131 | # one row from y not included 132 | expect_match(msg, "rows only in b\\s*\\(1\\)", all = FALSE) 133 | # three rows matched, no duplication 134 | expect_match(msg, "matched rows\\s*3", all = FALSE) 135 | expect_true(!any(grepl("duplicate", msg))) 136 | # total rows 137 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 138 | }) 139 | 140 | test_that("univariate full join has all columns, all rows", { 141 | msg <- capture_messages({ 142 | j <- tidylog::full_join(a, b, "x", relationship = "many-to-many") 143 | }) 144 | 145 | # one row from x included 146 | expect_match(msg, "rows only in a\\s*1", all = FALSE) 147 | # one row from y included 148 | expect_match(msg, "rows only in b\\s*1", all = FALSE) 149 | # four rows matched, including duplicates 150 | expect_match(msg, "matched rows\\s*4", all = FALSE) 151 | expect_match(msg, "duplicate", all = FALSE) 152 | # total rows 153 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 154 | }) 155 | 156 | test_that("univariate left join has all columns, all rows", { 157 | msg <- capture_messages({ 158 | j <- tidylog::left_join(a, b, "x", relationship = "many-to-many") 159 | }) 160 | 161 | # one row from x included 162 | expect_match(msg, "rows only in a\\s*1", all = FALSE) 163 | # one row from y not included 164 | expect_match(msg, "rows only in b\\s*\\(1\\)", all = FALSE) 165 | # four rows matched, including duplicates 166 | expect_match(msg, "matched rows\\s*4", all = FALSE) 167 | expect_match(msg, "duplicate", all = FALSE) 168 | # total rows 169 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 170 | }) 171 | 172 | test_that("univariate right join has all columns, all rows", { 173 | msg <- capture_messages({ 174 | j <- tidylog::right_join(a, b, "x", relationship = "many-to-many") 175 | }) 176 | 177 | # one row from x not included 178 | expect_match(msg, "rows only in a\\s*\\(1\\)", all = FALSE) 179 | # one row from y included 180 | expect_match(msg, "rows only in b\\s*1", all = FALSE) 181 | # four rows matched, including duplicates 182 | expect_match(msg, "matched rows\\s*4", all = FALSE) 183 | expect_match(msg, "duplicate", all = FALSE) 184 | # total rows 185 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 186 | }) 187 | 188 | test_that("univariate anti join has x columns, missing rows", { 189 | msg <- capture_messages({ 190 | j <- tidylog::anti_join(a, b, "x") 191 | }) 192 | 193 | # one row from x included 194 | expect_match(msg, "rows only in a\\s*1", all = FALSE) 195 | # one row from y not included 196 | expect_match(msg, "rows only in b\\s*\\(1\\)", all = FALSE) 197 | # three matched rows not included 198 | expect_match(msg, "matched rows\\s*\\(3\\)", all = FALSE) 199 | # total rows 200 | expect_match(msg, paste0("rows total\\s*", nrow(j)), all = FALSE) 201 | }) 202 | 203 | # edge cases for duplication 204 | 205 | test_that("no duplication", { 206 | a <- data.frame(x = c(1, 2, 3, 5), y = 1:4) 207 | b <- data.frame(x = c(1, 2, 3, 4), z = 1:4) 208 | 209 | msg <- capture_messages(tidylog::inner_join(a, b, "x")) 210 | expect_true(!any(grepl("duplicate", msg))) 211 | msg <- capture_messages(tidylog::full_join(a, b, "x")) 212 | expect_true(!any(grepl("duplicate", msg))) 213 | msg <- capture_messages(tidylog::left_join(a, b, "x")) 214 | expect_true(!any(grepl("duplicate", msg))) 215 | }) 216 | 217 | get_indices <- function(msg) { 218 | matched <- gregexpr(pattern =',', msg[c(2, 3, 4, 6)]) 219 | unique(sapply(matched, function(x) x[[1]])) 220 | } 221 | 222 | test_that("correct alignment", { 223 | msg <- function(fun) { 224 | capture_messages({ 225 | j <- fun(nycflights13::flights, nycflights13::weather, 226 | by = c("year", "month", "day", "origin", "hour", "time_hour")) 227 | }) 228 | } 229 | 230 | expect_equal(length(get_indices(msg(inner_join))), 1) 231 | expect_equal(length(get_indices(msg(semi_join))), 1) 232 | expect_equal(length(get_indices(msg(left_join))), 1) 233 | expect_equal(length(get_indices(msg(right_join))), 1) 234 | expect_equal(length(get_indices(msg(full_join))), 1) 235 | expect_equal(length(get_indices(msg(anti_join))), 1) 236 | }) 237 | 238 | 239 | test_that("correct alignment -- long df name", { 240 | msg <- function(fun) { 241 | capture_messages({ 242 | verylongnameverylongnameverylongname <- nycflights13::flights 243 | j <- fun(verylongnameverylongnameverylongname, nycflights13::weather, 244 | by = c("year", "month", "day", "origin", "hour", "time_hour")) 245 | }) 246 | } 247 | 248 | expect_equal(length(get_indices(msg(inner_join))), 1) 249 | expect_equal(length(get_indices(msg(semi_join))), 1) 250 | expect_equal(length(get_indices(msg(left_join))), 1) 251 | expect_equal(length(get_indices(msg(right_join))), 1) 252 | expect_equal(length(get_indices(msg(full_join))), 1) 253 | expect_equal(length(get_indices(msg(anti_join))), 1) 254 | 255 | msg <- function(fun) { 256 | capture_messages({ 257 | verylongnameverylongnameverylongname <- nycflights13::weather 258 | j <- fun(nycflights13::flights, verylongnameverylongnameverylongname, 259 | by = c("year", "month", "day", "origin", "hour", "time_hour")) 260 | }) 261 | } 262 | 263 | expect_equal(length(get_indices(msg(inner_join))), 1) 264 | expect_equal(length(get_indices(msg(semi_join))), 1) 265 | expect_equal(length(get_indices(msg(left_join))), 1) 266 | expect_equal(length(get_indices(msg(right_join))), 1) 267 | expect_equal(length(get_indices(msg(full_join))), 1) 268 | expect_equal(length(get_indices(msg(anti_join))), 1) 269 | }) 270 | -------------------------------------------------------------------------------- /tests/testthat/test_longer_wider.R: -------------------------------------------------------------------------------- 1 | library("dplyr") 2 | library("tidyr") 3 | library("tidylog") 4 | context("test_longer_wider") 5 | 6 | mtcars_with_id <- dplyr::mutate(mtcars, id = seq_len(dplyr::n())) 7 | mtcars_with_name <- tidyr::as_tibble(mtcars, rownames = "name") 8 | 9 | test_tidyr_fun <- function(fun_name, tidylog_fun, tidyr_fun, data, ..., expected_nrow, expected_ncol) { 10 | # Test that tidylog output matches tidyr. 11 | test_that(fun_name, { 12 | expect_message({ 13 | outlog <- tidylog_fun(data, ...) 14 | }) 15 | expect_equal(nrow(outlog), expected_nrow) 16 | expect_equal(ncol(outlog), expected_ncol) 17 | 18 | expect_silent({ 19 | outtidy <- tidyr_fun(data, ...) 20 | }) 21 | 22 | expect_equal(outlog, outtidy) 23 | }) 24 | 25 | # Test that argument order doesn't matter. 26 | test_that(glue::glue("{fun_name}: argument order"), { 27 | expect_message({ 28 | out_ab <- tidylog_fun(data = data, ...) 29 | }) 30 | 31 | expect_message({ 32 | out_ba <- tidylog_fun(..., data = data) 33 | }) 34 | 35 | expect_equal(out_ab, out_ba) 36 | }) 37 | } 38 | 39 | 40 | test_tidyr_fun( 41 | "pivot_longer", tidylog::pivot_longer, tidyr::pivot_longer, 42 | mtcars_with_id, -id, names_to = "var", values_to = "value", 43 | expected_nrow = 352, expected_ncol = 3 44 | ) 45 | 46 | 47 | test_tidyr_fun( 48 | "pivot_wider", tidylog::pivot_wider, tidyr::pivot_wider, 49 | mtcars, names_from = vs, values_from = cyl, 50 | expected_nrow = 32, expected_ncol = 11 51 | ) 52 | 53 | test_tidyr_fun( 54 | "gather", tidylog::gather, tidyr::gather, 55 | mtcars, 56 | expected_nrow = 352, expected_ncol = 2 57 | ) 58 | 59 | test_tidyr_fun( 60 | "spread", tidylog::spread, tidyr::spread, 61 | mtcars, hp, carb, 62 | expected_nrow = 32, expected_ncol = 31 63 | ) 64 | 65 | test_tidyr_fun( 66 | "separate_wider_delim", tidylog::separate_wider_delim, tidyr::separate_wider_delim, 67 | mtcars_with_name, name, " ", names=c("A", "B"), 68 | too_few = "align_start", too_many = "merge", 69 | expected_nrow = 32, expected_ncol = 13 70 | ) 71 | 72 | test_tidyr_fun( 73 | "separate_wider_position", tidylog::separate_wider_position, tidyr::separate_wider_position, 74 | mtcars_with_name, name, c("A" = 3, "B" = 4), 75 | too_few = "align_start", too_many = "drop", 76 | expected_nrow = 32, expected_ncol = 13 77 | ) 78 | 79 | test_tidyr_fun( 80 | "separate_wider_regex", tidylog::separate_wider_regex, tidyr::separate_wider_regex, 81 | mtcars_with_name, name, c("A" = "\\w+", "\\s", "B" = ".*"), 82 | too_few = "align_start", 83 | expected_nrow = 32, expected_ncol = 13 84 | ) 85 | -------------------------------------------------------------------------------- /tests/testthat/test_mutate.R: -------------------------------------------------------------------------------- 1 | context("test_mutate") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("mutate", { 6 | expect_message({ 7 | out <- tidylog::mutate(mtcars, test = TRUE) 8 | }) 9 | expect_equal(all(out$test), TRUE) 10 | 11 | # factor to factor 12 | f <- function() tidylog::mutate(iris, Species = recode(Species, "virginica" = "v")) 13 | expect_message(f(), "changed 50 values.*0 new NA") 14 | 15 | # factor to factor, with missings 16 | f <- function() tidylog::mutate(iris, Species = na_if(Species, "virginica")) 17 | expect_message(f(), "changed 50 values.*50 new NA") 18 | 19 | # numeric to numeric 20 | f <- function() tidylog::mutate(iris, Sepal.Length = round(Sepal.Length)) 21 | expect_message(f(), "changed 133 values.*0 new NA") 22 | 23 | # character to character 24 | iris2 <- dplyr::mutate(iris, Species = as.character(Species)) 25 | f <- function() tidylog::mutate(iris2, Species = ifelse(Species == "virginica", "v", Species)) 26 | expect_message(f(), "changed 50 values.*0 new NA") 27 | 28 | # factor to character 29 | f <- function() tidylog::mutate(iris, Species = as.character(Species)) 30 | expect_message(f(), "from factor to character.*0 new NA") 31 | 32 | # factor to 100% missing 33 | f <- function() tidylog::mutate(iris, Species = NA) 34 | expect_message(f(), "now 100% NA") 35 | 36 | # double to character 37 | f <- function() tidylog::mutate(iris, Sepal.Length = as.character(Sepal.Length)) 38 | expect_message(f(), "from double to character.*0 new NA") 39 | 40 | # character to ordered factor 41 | iris2 <- dplyr::mutate(iris, Species = as.character(Species)) 42 | f <- function() tidylog::mutate(iris2, Species = ordered(Species)) 43 | expect_message(f(), "from character to ordered factor.*0 new NA") 44 | 45 | # ordered factor to character 46 | iris2 <- dplyr::mutate(iris, Species = ordered(Species)) 47 | f <- function() tidylog::mutate(iris2, Species = as.character(Species)) 48 | expect_message(f(), "from ordered factor to character.*0 new NA") 49 | 50 | # character to Date 51 | iris2 <- dplyr::mutate(iris, date = "2016-01-01") 52 | f <- function() tidylog::mutate(iris2, date = as.Date(date)) 53 | expect_message(f(), "from character to Date.*0 new NA") 54 | }) 55 | 56 | test_that("missings", { 57 | # same type, increase missings 58 | f <- function() tidylog::mutate(iris, Sepal.Length = ifelse(Sepal.Length > 5, NA, Sepal.Length)) 59 | expect_message(f(), "changed.*(118 new NA)") 60 | 61 | # same type, reduce missings 62 | iris2 <- dplyr::mutate(iris, Sepal.Length = ifelse(Sepal.Length > 5, NA, Sepal.Length)) 63 | f <- function() tidylog::mutate(iris2, Sepal.Length = 1) 64 | expect_message(f(), "changed.*(118 fewer NA)") 65 | 66 | # same type, same missings 67 | f <- function() tidylog::mutate(iris, Sepal.Length = sample(Sepal.Length)) 68 | expect_message(f(), "changed.*(0 new NA)") 69 | 70 | # double to integer, increase missings 71 | f <- function() tidylog::mutate(iris, 72 | Sepal.Length = as.integer(ifelse(Sepal.Length > 5, NA, Sepal.Length))) 73 | expect_message(f(), "converted.*to integer.*(118 new NA)") 74 | 75 | # double to integer, reduce missings 76 | iris2 <- dplyr::mutate(iris, Sepal.Length = ifelse(Sepal.Length > 5, NA, Sepal.Length)) 77 | f <- function() tidylog::mutate(iris2, Sepal.Length = as.integer(1)) 78 | expect_message(f(), "converted.*to integer.*(118 fewer NA)") 79 | 80 | # double to integer, same missings 81 | f <- function() tidylog::mutate(iris, 82 | Sepal.Length = as.integer(sample(Sepal.Length))) 83 | expect_message(f(), "converted.*to integer.*(0 new NA)") 84 | }) 85 | 86 | test_that("transmute", { 87 | expect_message({ 88 | out <- tidylog::transmute(mtcars, test = TRUE) 89 | }) 90 | expect_equal(all(out$test), TRUE) 91 | expect_equal(ncol(out), 1) 92 | 93 | f <- function() tidylog::transmute(mtcars) 94 | expect_message(f(), regexp = "dropped all variables") 95 | }) 96 | 97 | test_that("percent function", { 98 | iris2 <- bind_rows(iris, iris) 99 | 100 | # 100% change 101 | f <- function() tidylog::mutate(iris2, Sepal.Length = 1) 102 | expect_message(f(), regexp = "100%") 103 | 104 | # <1% change, but no 0% 105 | f <- function() tidylog::mutate(iris2, 106 | Sepal.Length = ifelse(row_number() == 1, 100, Sepal.Length)) 107 | expect_message(f(), regexp = "<1%") 108 | 109 | # >99% change, but no 100% 110 | f <- function() tidylog::mutate(iris2, 111 | Sepal.Length = ifelse(row_number() != 1, 100, Sepal.Length)) 112 | expect_message(f(), regexp = ">99%") 113 | 114 | # no changes 115 | f <- function() tidylog::mutate(iris2, Sepal.Length = Sepal.Length) 116 | expect_message(f(), regexp = "no changes") 117 | 118 | # 0% 119 | f <- function() tidylog::mutate(iris2, test = 1) 120 | expect_message(f(), regexp = "0%") 121 | }) 122 | 123 | test_that("add_tally", { 124 | expect_message({ 125 | out <- mtcars %>% 126 | tidylog::group_by(cyl) %>% 127 | tidylog::add_tally() 128 | }) 129 | expect_equal(nrow(out), nrow(mtcars)) 130 | expect_equal(ncol(out), ncol(mtcars) + 1) 131 | }) 132 | 133 | test_that("add_count", { 134 | expect_message({ 135 | out <- mtcars %>% 136 | tidylog::group_by(gear) %>% 137 | tidylog::add_count(carb) 138 | }) 139 | expect_equal(nrow(out), nrow(mtcars)) 140 | expect_equal(ncol(out), ncol(mtcars) + 1) 141 | }) 142 | 143 | test_that("mutate: scoped variants", { 144 | expect_message({ 145 | out <- tidylog::mutate_all(mtcars, round) 146 | }) 147 | expect_equal(out, dplyr::mutate_all(mtcars, round)) 148 | 149 | expect_message({ 150 | out <- tidylog::mutate_at(mtcars, vars(mpg:disp), scale) 151 | }) 152 | expect_equal(out, dplyr::mutate_at(mtcars, vars(mpg:disp), scale)) 153 | 154 | expect_message({ 155 | out <- tidylog::mutate_if(iris, is.factor, as.character) 156 | }) 157 | expect_equal(out, dplyr::mutate_if(iris, is.factor, as.character)) 158 | }) 159 | 160 | test_that("transmute: scoped variants", { 161 | expect_message({ 162 | out <- tidylog::transmute_all(mtcars, round) 163 | }) 164 | expect_equal(out, dplyr::transmute_all(mtcars, round)) 165 | 166 | expect_message({ 167 | out <- tidylog::transmute_at(mtcars, vars(mpg:disp), scale) 168 | }) 169 | expect_equal(out, dplyr::transmute_at(mtcars, vars(mpg:disp), scale)) 170 | 171 | expect_message({ 172 | out <- tidylog::transmute_if(iris, is.factor, as.character) 173 | }) 174 | expect_equal(out, dplyr::transmute_if(iris, is.factor, as.character)) 175 | }) 176 | 177 | test_that("mutate: argument order", { 178 | expect_message({ 179 | out <- tidylog::mutate(test = TRUE, .data = mtcars) 180 | }) 181 | expect_equal(all(out$test), TRUE) 182 | }) 183 | 184 | test_that("transmute: argument order", { 185 | expect_message({ 186 | out <- tidylog::transmute(test = TRUE, .data = mtcars) 187 | }) 188 | expect_equal(all(out$test), TRUE) 189 | expect_equal(ncol(out), 1) 190 | }) 191 | 192 | test_that("mutate/transmute: partial matching", { 193 | f <- function() tidylog::mutate(mtcars, f = 1) 194 | expect_message(f(), "new variable 'f'") 195 | f <- function() tidylog::transmute(mtcars, fun = 1) 196 | expect_message(f(), "new variable 'fun'") 197 | }) 198 | 199 | test_that("tidyr::replace_na", { 200 | df <- tibble(x = c(1, 2, NA), y = c("a", NA, "b")) 201 | 202 | expect_message({ 203 | out <- tidylog::replace_na(df, list(x = 0, y = "unknown")) 204 | }) 205 | # with vector 206 | expect_silent(dplyr::mutate(df, x = replace_na(x, 0))) 207 | 208 | expect_equal(tidyr::replace_na(df, list(x = 0, y = "unknown")), out) 209 | }) 210 | 211 | test_that("tidyr::fill", { 212 | df <- data.frame(Month = 1:12, Year = c(2000, rep(NA, 11))) 213 | expect_message({ 214 | out <- tidylog::fill(df, Year) 215 | }) 216 | 217 | expect_equal(tidyr::fill(df, Year), out) 218 | }) 219 | 220 | test_that("mutate: list columns", { 221 | df <- tibble(x = list(1, 2)) 222 | # from list to scalar 223 | expect_message({ 224 | out <- tidylog::mutate(df, x = 1) 225 | }, "converted.*from list to") 226 | # from list to identical list 227 | expect_message({ 228 | out <- tidylog::mutate(df, x = list(1, 2)) 229 | }, "no changes") 230 | # from list to different list 231 | expect_message({ 232 | out <- tidylog::mutate(df, x = lapply(x, function(v) v * 100)) 233 | }, "changed 2 values") 234 | # from scalar to list 235 | df <- tibble(x = 1:2) 236 | expect_message({ 237 | out <- tidylog::mutate(df, x = as.list(x)) 238 | }, "converted.*from integer to list") 239 | }) 240 | 241 | test_that("mutate: ordered factors", { 242 | df <- tibble(x = ordered(c("apple", "bear", "banana", "dear"))) 243 | rec <- forcats::fct_recode(df$x, fruit = "apple", fruit = "banana") 244 | # new variable 245 | expect_message({ 246 | new <- tidylog::mutate(df, 247 | y = forcats::fct_recode(x, fruit = "apple", fruit = "banana")) 248 | }, "new variable 'y' (ordered factor) with 3 unique values", fixed = TRUE) 249 | expect_true(all(new$y == rec)) 250 | 251 | # overwriting 252 | expect_message({ 253 | new <- tidylog::mutate(df, 254 | x = forcats::fct_recode(x, fruit = "apple", fruit = "banana")) 255 | }, "changed 2 values") 256 | expect_true(all(new$x == rec)) 257 | }) 258 | 259 | test_that("mutate: variable type", { 260 | expect_message({ 261 | tidylog::mutate(tibble(x = 1:10), y = 1) 262 | }, "new variable 'y' (double)", fixed = TRUE) 263 | 264 | expect_message({ 265 | tidylog::mutate(tibble(x = 1:10), y = "a") 266 | }, "new variable 'y' (character)", fixed = TRUE) 267 | 268 | expect_message({ 269 | tidylog::mutate(tibble(x = 1:10), y = as.factor("a")) 270 | }, "new variable 'y' (factor)", fixed = TRUE) 271 | }) 272 | 273 | test_that("mutate: units", { 274 | expect_message({ 275 | mutate(tibble(a = 1:2), a = units::set_units(a, mg)) 276 | }, "mutate: converted 'a' from integer to units (0 new NA)", fixed = TRUE) 277 | }) 278 | 279 | test_that("mutate: formatting", { 280 | expect_message({ 281 | mutate(tibble(x = rep(NA_real_, 1000000)), x = 1) 282 | }, "mutate: changed 1,000,000 values (100%) of 'x' (1,000,000 fewer NAs)", fixed = TRUE) 283 | 284 | expect_message({ 285 | mutate(tibble(x = rep(NA_real_, 1000000)), x = ifelse(row_number() == 1, 1, x)) 286 | }, "mutate: changed one value (<1%) of 'x' (one fewer NA)", fixed = TRUE) 287 | 288 | expect_message({ 289 | mutate(tibble(x = 1:10000), x = ifelse(row_number() == 1, NA, x)) 290 | }, "mutate: changed one value (<1%) of 'x' (one new NA)", fixed = TRUE) 291 | 292 | expect_message({ 293 | mutate(tibble(x = 1:10000), x = ifelse(row_number() <= 2, NA, x)) 294 | }, "mutate: changed 2 values (<1%) of 'x' (2 new NAs)", fixed = TRUE) 295 | }) 296 | 297 | test_that("mutate: drop column", { 298 | d <- tibble(a = 1, b = 2, c = 3) 299 | expect_message(mutate(d, a = NULL), "dropped") 300 | expect_message(mutate(d, a = NULL, b = 10), "dropped") 301 | }) -------------------------------------------------------------------------------- /tests/testthat/test_rename.R: -------------------------------------------------------------------------------- 1 | context("test_rename") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("rename", { 6 | expect_message({ 7 | out <- tidylog::rename(mtcars, MPG = mpg, CYL = cyl) 8 | }) 9 | expect_equal(ncol(out), ncol(dplyr::rename(mtcars, MPG = mpg, CYL = cyl))) 10 | 11 | expect_silent({ 12 | out <- dplyr::rename(mtcars, MPG = mpg, CYL = cyl) 13 | }) 14 | }) 15 | 16 | test_that("rename: scoped variants", { 17 | is_whole <- function(x) all(floor(x) == x) 18 | 19 | expect_message({ 20 | out <- tidylog::rename_all(mtcars, toupper) 21 | }) 22 | expect_equal(out, dplyr::rename_all(mtcars, toupper)) 23 | 24 | expect_message({ 25 | out <- tidylog::rename_if(mtcars, is_whole, toupper) 26 | }) 27 | expect_equal(out, dplyr::rename_if(mtcars, is_whole, toupper)) 28 | 29 | expect_message({ 30 | out <- tidylog::rename_at(mtcars, vars(-(1:3)), toupper) 31 | }) 32 | expect_equal(out, dplyr::rename_at(mtcars, vars(-(1:3)), toupper)) 33 | 34 | }) 35 | 36 | test_that("rename: argument order", { 37 | expect_message({ 38 | out <- tidylog::rename(MPG = mpg, CYL = cyl, .data = mtcars) 39 | }) 40 | expect_equal(ncol(out), ncol(dplyr::rename(mtcars, MPG = mpg, CYL = cyl))) 41 | }) 42 | 43 | test_that("rename_with", { 44 | expect_message({ 45 | out <- tidylog::rename_with(iris, toupper) 46 | }) 47 | expect_equal(out, dplyr::rename_with(iris, toupper)) 48 | }) 49 | -------------------------------------------------------------------------------- /tests/testthat/test_select.R: -------------------------------------------------------------------------------- 1 | context("test_select") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("select", { 6 | # no changes 7 | f <- function() tidylog::select(mtcars, everything()) 8 | expect_message(out <- f(), "no changes") 9 | expect_equal(out, dplyr::select(mtcars, everything())) 10 | 11 | # only order changed 12 | f <- function() tidylog::select(mtcars, hp, everything()) 13 | expect_message(out <- f(), "columns reordered") 14 | expect_equal(out, dplyr::select(mtcars, hp, everything())) 15 | 16 | # dropped some 17 | f <- function() tidylog::select(mtcars, -mpg, -cyl, -disp) 18 | expect_message(out <- f(), "dropped 3") 19 | expect_equal(out, dplyr::select(mtcars, -mpg, -cyl, -disp)) 20 | 21 | # dropped all 22 | f <- function() tidylog::select(mtcars, -everything()) 23 | expect_message(out <- f(), "dropped all variables") 24 | expect_equal(out, dplyr::select(mtcars, -everything())) 25 | 26 | # renamed 27 | small_mtcars <- dplyr::select(mtcars, mpg, cyl, hp) 28 | f <- function() tidylog::select(small_mtcars, a = mpg, b = cyl, c = hp) 29 | expect_message(out <- f(), "renamed 3") 30 | expect_equal(out, dplyr::select(small_mtcars, a = mpg, b = cyl, c = hp)) 31 | 32 | # dropped and renamed 33 | f <- function() tidylog::select(small_mtcars, a = mpg, b = cyl) 34 | expect_message(out <- f(), "renamed 2.*dropped one") 35 | expect_equal(out, dplyr::select(small_mtcars, a = mpg, b = cyl)) 36 | 37 | # dplyr call is silent 38 | expect_silent({ 39 | out <- dplyr::select(mtcars, mpg, cyl) 40 | }) 41 | }) 42 | 43 | test_that("select: scoped variants", { 44 | is_whole <- function(x) all(floor(x) == x) 45 | 46 | expect_message({ 47 | out <- tidylog::select_all(mtcars, toupper) 48 | }) 49 | expect_equal(out, dplyr::select_all(mtcars, toupper)) 50 | 51 | expect_message({ 52 | out <- tidylog::select_if(mtcars, is_whole, toupper) 53 | }) 54 | expect_equal(out, dplyr::select_if(mtcars, is_whole, toupper)) 55 | 56 | expect_message({ 57 | out <- tidylog::select_at(mtcars, vars(-everything())) 58 | }) 59 | expect_equal(out, dplyr::select_at(mtcars, vars(-everything()))) 60 | 61 | }) 62 | 63 | test_that("select: argument order", { 64 | expect_message({ 65 | out <- tidylog::select(mpg, cyl, .data = mtcars) 66 | }) 67 | expect_equal(ncol(out), ncol(dplyr::select(mtcars, mpg, cyl))) 68 | }) 69 | 70 | test_that("relocate", { 71 | df <- tibble(a = 1, b = 1, c = 1, d = "a", e = "a", f = "a") 72 | 73 | expect_message({ 74 | out <- tidylog::relocate(df, f) 75 | }, "columns reordered") 76 | expect_equal(out, dplyr::relocate(df, f)) 77 | 78 | expect_message({ 79 | out <- tidylog::relocate(df, where(is.character)) 80 | }, "columns reordered") 81 | expect_equal(out, dplyr::relocate(df, where(is.character))) 82 | }) 83 | 84 | -------------------------------------------------------------------------------- /tests/testthat/test_summarize.R: -------------------------------------------------------------------------------- 1 | context("test_summarize") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("summarize", { 6 | expect_message({ 7 | out <- tidylog::summarize(mtcars, test = TRUE) 8 | }) 9 | expect_equal(nrow(out), 1) 10 | 11 | expect_message({ 12 | out <- tidylog::summarise(mtcars, test = TRUE) 13 | }) 14 | expect_equal(nrow(out), 1) 15 | 16 | expect_message({ 17 | out <- mtcars %>% 18 | tidylog::group_by(cyl, carb) %>% 19 | tidylog::summarize(avg_mpg = mean(mpg)) 20 | }) 21 | expect_equal(nrow(out), 9) 22 | 23 | expect_silent({ 24 | out <- dplyr::summarise(mtcars) 25 | }) 26 | }) 27 | 28 | test_that("tally", { 29 | expect_message({ 30 | out <- mtcars %>% 31 | tidylog::group_by(cyl) %>% 32 | tidylog::tally() 33 | }) 34 | expect_equal(nrow(out), 3) 35 | expect_equal(ncol(out), 2) 36 | }) 37 | 38 | test_that("count", { 39 | expect_message({ 40 | out <- mtcars %>% 41 | tidylog::group_by(gear) %>% 42 | tidylog::count(carb) 43 | }) 44 | expect_equal(nrow(out), 11) 45 | expect_equal(ncol(out), 3) 46 | }) 47 | 48 | test_that("uncount", { 49 | expect_message({ 50 | df <- tibble(x = c("a", "b"), n = c(1, 2)) 51 | out <- uncount(df, n) 52 | }) 53 | expect_equal(nrow(out), 3) 54 | expect_equal(ncol(out), 1) 55 | }) 56 | 57 | test_that("summarize: scoped variants", { 58 | expect_message({ 59 | out <- tidylog::summarize_all(mtcars, max) 60 | }) 61 | expect_equal(out, dplyr::summarize_all(mtcars, max)) 62 | 63 | expect_message({ 64 | out <- tidylog::summarise_all(mtcars, max) 65 | }) 66 | expect_equal(out, dplyr::summarise_all(mtcars, max)) 67 | 68 | expect_message({ 69 | out <- tidylog::summarize_if(mtcars, is.numeric, mean, na.rm = TRUE) 70 | }) 71 | expect_equal(out, dplyr::summarize_if(mtcars, is.numeric, mean, na.rm = TRUE)) 72 | 73 | expect_message({ 74 | out <- tidylog::summarise_if(mtcars, is.numeric, mean, na.rm = TRUE) 75 | }) 76 | expect_equal(out, dplyr::summarise_if(mtcars, is.numeric, mean, na.rm = TRUE)) 77 | 78 | expect_message({ 79 | out <- tidylog::summarize_at(mtcars, c("mpg", "hp"), mean) 80 | }) 81 | expect_equal(out, dplyr::summarize_at(mtcars, c("mpg", "hp"), mean)) 82 | 83 | expect_message({ 84 | out <- tidylog::summarise_at(mtcars, c("mpg", "hp"), mean) 85 | }) 86 | expect_equal(out, dplyr::summarise_at(mtcars, c("mpg", "hp"), mean)) 87 | }) 88 | 89 | test_that("summarize: argument order", { 90 | expect_message({ 91 | out <- tidylog::summarize(avg = mean(mpg), .data = mtcars) 92 | }) 93 | expect_equal(nrow(out), 1) 94 | }) 95 | -------------------------------------------------------------------------------- /tests/testthat/test_tidylog.R: -------------------------------------------------------------------------------- 1 | context("test_tidylog") 2 | library("dplyr") 3 | library("tidylog") 4 | 5 | test_that("tidylog", { 6 | f <- function() tidylog::tidylog(mtcars) 7 | expect_message(f(), regexp = "data\\.frame.*32 rows.*11 columns") 8 | 9 | f <- function() tidylog::tidylog(as_tibble(mtcars)) 10 | expect_message(f(), regexp = "tibble.*32 rows.*11 columns") 11 | 12 | f <- function() tidylog::tidylog(group_by(mtcars, cyl, mpg)) 13 | expect_message(f(), regexp = "grouped tibble.*32 rows.*11 columns") 14 | }) 15 | 16 | test_that("logging on/off", { 17 | options("tidylog.display" = list()) 18 | expect_silent(tidylog::filter(mtcars, mpg > 20)) 19 | expect_silent(tidylog::select(mtcars, mpg)) 20 | expect_silent(tidylog::rename(mtcars, MPG = mpg)) 21 | expect_silent(tidylog::group_by(mtcars, mpg)) 22 | expect_silent(tidylog::left_join(dplyr::band_members, dplyr::band_instruments, by = "name")) 23 | expect_silent(tidylog::mutate(mtcars, test = TRUE)) 24 | expect_silent(tidylog::summarize(mtcars, test = TRUE)) 25 | expect_silent(tidylog::gather(mtcars)) 26 | expect_silent(tidylog::spread(mtcars, cyl, hp)) 27 | expect_silent(tidylog::tidylog(mtcars)) 28 | 29 | # warnings 30 | options("tidylog.display" = "x") 31 | expect_warning(filter(mtcars, mpg > 20)) 32 | 33 | options("tidylog.display" = list("x", message)) 34 | expect_warning(filter(mtcars, mpg > 20)) 35 | 36 | # back to default 37 | options("tidylog.display" = NULL) 38 | expect_message(filter(mtcars, mpg > 20)) 39 | }) 40 | -------------------------------------------------------------------------------- /tidylog.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: No 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 4 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/benchmarks.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Benchmarks" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{benchmarks} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>" 14 | ) 15 | ``` 16 | 17 | Using `tidylog` adds a small overhead to each function call. For instance, because tidylog needs 18 | to figure out how many rows were dropped when you use `tidylog::filter`, 19 | this call will be a bit slower than using `dplyr::filter` directly. 20 | The overhead is usually not noticeable, but can be for larger datasets, especially when using joins. 21 | The benchmarks below give some impression of how large the overhead is. 22 | 23 | 24 | ```{r message = FALSE, warning = FALSE} 25 | library("dplyr") 26 | library("tidylog", warn.conflicts = FALSE) 27 | library("bench") 28 | library("knitr") 29 | ``` 30 | 31 | ## filter 32 | 33 | On a small dataset: 34 | 35 | ```{r message = FALSE} 36 | bench::mark( 37 | dplyr::filter(mtcars, cyl == 4), 38 | tidylog::filter(mtcars, cyl == 4), iterations = 100 39 | ) %>% 40 | dplyr::select(expression, min, median, n_itr) %>% 41 | kable() 42 | ``` 43 | 44 | On a larger dataset: 45 | 46 | ```{r message = FALSE} 47 | df <- tibble(x = rnorm(100000)) 48 | 49 | bench::mark( 50 | dplyr::filter(df, x > 0), 51 | tidylog::filter(df, x > 0), iterations = 100 52 | ) %>% 53 | dplyr::select(expression, min, median, n_itr) %>% 54 | kable() 55 | ``` 56 | 57 | ## mutate 58 | 59 | On a small dataset: 60 | 61 | ```{r message = FALSE} 62 | bench::mark( 63 | dplyr::mutate(mtcars, cyl = as.factor(cyl)), 64 | tidylog::mutate(mtcars, cyl = as.factor(cyl)), iterations = 100 65 | ) %>% 66 | dplyr::select(expression, min, median, n_itr) %>% 67 | kable() 68 | ``` 69 | 70 | On a larger dataset: 71 | 72 | ```{r message = FALSE} 73 | df <- tibble(x = round(runif(10000) * 10)) 74 | 75 | bench::mark( 76 | dplyr::mutate(df, x = as.factor(x)), 77 | tidylog::mutate(df, x = as.factor(x)), iterations = 100 78 | ) %>% 79 | dplyr::select(expression, min, median, n_itr) %>% 80 | kable() 81 | ``` 82 | 83 | ## joins 84 | 85 | Joins are the most expensive operation, as tidylog has to do 86 | two additional joins behind the scenes. 87 | 88 | On a small dataset: 89 | 90 | ```{r message = FALSE} 91 | bench::mark( 92 | dplyr::inner_join(band_members, band_instruments, by = "name"), 93 | tidylog::inner_join(band_members, band_instruments, by = "name"), iterations = 100 94 | ) %>% 95 | dplyr::select(expression, min, median, n_itr) %>% 96 | kable() 97 | ``` 98 | 99 | On a larger dataset (with many row duplications): 100 | 101 | ```{r message = FALSE} 102 | N <- 1000 103 | df1 <- tibble(x1 = rnorm(N), key = round(runif(N) * 10)) 104 | df2 <- tibble(x2 = rnorm(N), key = round(runif(N) * 10)) 105 | 106 | bench::mark( 107 | dplyr::inner_join(df1, df2, by = "key"), 108 | tidylog::inner_join(df1, df2, by = "key"), iterations = 100 109 | ) %>% 110 | dplyr::select(expression, min, median, n_itr) %>% 111 | kable() 112 | ``` 113 | 114 | --------------------------------------------------------------------------------