From fb138fcc42ea4c9da1e64f6fa46124c8e977a1a5 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 14:22:40 +0200 Subject: [PATCH 1/8] Replace lahman_dt() function removed from new dplyr --- tests/testthat/helper-data.R | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/testthat/helper-data.R diff --git a/tests/testthat/helper-data.R b/tests/testthat/helper-data.R new file mode 100644 index 000000000..bac91b43f --- /dev/null +++ b/tests/testthat/helper-data.R @@ -0,0 +1,4 @@ + +lahman_dt <- function() { + dtplyr::src_dt("Lahman") +} From 8bafc2af2e8a635cc38a6364b68798b7d77cca30 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 14:29:30 +0200 Subject: [PATCH 2/8] Conditionally export methods for non-underscored generics --- NAMESPACE | 50 +++++++++++++++++++++++++++++++++++++++ R/do.R | 9 ++++++++ R/grouped-dt.r | 9 ++++++++ R/sets.R | 9 ++++++++ R/tbl-dt.r | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 577e07275..28908c68a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,55 @@ # Generated by roxygen2: do not edit by hand + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,arrange) + S3method(arrange,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,distinct) + S3method(distinct,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,do) + S3method(do,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,filter) + S3method(filter,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,group_by) + S3method(group_by,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,mutate) + S3method(mutate,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,rename) + S3method(rename,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,select) + S3method(select,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,slice) + S3method(slice,data.table) +} + +if (utils::packageVersion("dplyr") > "0.5.0") { + importFrom(dplyr,summarise) + S3method(summarise,data.table) +} S3method(all.equal,tbl_dt) S3method(anti_join,data.table) S3method(arrange_,data.table) diff --git a/R/do.R b/R/do.R index 6dff3b675..a5008b460 100644 --- a/R/do.R +++ b/R/do.R @@ -1,3 +1,12 @@ +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,do) +#' S3method(do,data.table) +#' } +do.data.table <- function(.data, ...) { + do_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr do_ #' @export do_.data.table <- function(.data, ..., .dots) { diff --git a/R/grouped-dt.r b/R/grouped-dt.r index 7613fb2c6..d32cc9269 100644 --- a/R/grouped-dt.r +++ b/R/grouped-dt.r @@ -68,6 +68,15 @@ n_groups.grouped_dt <- function(x) { nrow(dt_subset(x, , quote(list(1)))) } +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,group_by) +#' S3method(group_by,data.table) +#' } +group_by.data.table <- function(.data, ..., add = FALSE) { + group_by_(.data, .dots = lazyeval::lazy_dots(...), add = add) +} + #' @export #' @importFrom dplyr group_by_ group_by_.data.table <- function(.data, ..., .dots, add = FALSE) { diff --git a/R/sets.R b/R/sets.R index 871698d1a..79050984b 100644 --- a/R/sets.R +++ b/R/sets.R @@ -1,6 +1,15 @@ # Set operations --------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,distinct) +#' S3method(distinct,data.table) +#' } +distinct.data.table <- function(.data, ..., .keep_all = FALSE) { + distinct_(.data, .dots = lazyeval::lazy_dots(...), .keep_all = .keep_all) +} + #' @export #' @importFrom dplyr distinct_ distinct_.data.table <- function(.data, ..., .dots, .keep_all = FALSE) { diff --git a/R/tbl-dt.r b/R/tbl-dt.r index 5a5b5b37d..ab14cac33 100644 --- a/R/tbl-dt.r +++ b/R/tbl-dt.r @@ -152,6 +152,15 @@ and_expr <- function(exprs) { left } +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,filter) +#' S3method(filter,data.table) +#' } +filter.data.table <- function(.data, ...) { + filter_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr filter_ #' @export filter_.grouped_dt <- function(.data, ..., .dots) { @@ -178,6 +187,15 @@ filter_.data.table <- function(.data, ..., .dots) { # Summarise -------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,summarise) +#' S3method(summarise,data.table) +#' } +summarise.data.table <- function(.data, ...) { + summarise_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr summarise_ #' @export summarise_.grouped_dt <- function(.data, ..., .dots) { @@ -199,6 +217,15 @@ summarise_.data.table <- function(.data, ..., .dots) { # Mutate ----------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,mutate) +#' S3method(mutate,data.table) +#' } +mutate.data.table <- function(.data, ...) { + mutate_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr mutate_ #' @export mutate_.grouped_dt <- function(.data, ..., .dots) { @@ -230,6 +257,15 @@ mutate_.data.table <- function(.data, ..., .dots) { # Arrange ---------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,arrange) +#' S3method(arrange,data.table) +#' } +arrange.data.table <- function(.data, ...) { + arrange_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr arrange_ #' @export arrange_.grouped_dt <- function(.data, ..., .dots) { @@ -254,6 +290,15 @@ arrange_.data.table <- function(.data, ..., .dots) { # Select ----------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,select) +#' S3method(select,data.table) +#' } +select.data.table <- function(.data, ...) { + select_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr select_ #' @export select_.grouped_dt <- function(.data, ..., .dots) { @@ -283,6 +328,15 @@ select_.tbl_dt <- function(.data, ..., .dots) { # Rename ----------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,rename) +#' S3method(rename,data.table) +#' } +rename.data.table <- function(.data, ...) { + rename_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr rename_ #' @export rename_.grouped_dt <- function(.data, ..., .dots) { @@ -313,6 +367,15 @@ rename_.tbl_dt <- function(.data, ..., .dots) { # Slice ------------------------------------------------------------------- +#' @rawNamespace +#' if (utils::packageVersion("dplyr") > "0.5.0") { +#' importFrom(dplyr,slice) +#' S3method(slice,data.table) +#' } +slice.data.table <- function(.data, ...) { + slice_(.data, .dots = lazyeval::lazy_dots(...)) +} + #' @importFrom dplyr slice_ #' @export slice_.grouped_dt <- function(.data, ..., .dots) { From 5366845731bd121eeecae3758e21d3e818a39815 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 14:30:13 +0200 Subject: [PATCH 3/8] Redocument --- DESCRIPTION | 2 +- man/grouped_dt.Rd | 1 - man/join.tbl_dt.Rd | 7 +++---- man/src_local.Rd | 1 - man/tbl_dt.Rd | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3c4a8dabe..fb06d9772 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,6 +18,6 @@ Suggests: testthat, covr LazyData: true -RoxygenNote: 5.0.1 +RoxygenNote: 6.0.1 URL: https://github.com/hadley/dtplyr BugReports: https://github.com/hadley/dtplyr/issues diff --git a/man/grouped_dt.Rd b/man/grouped_dt.Rd index 523f066ee..1fe04e80b 100644 --- a/man/grouped_dt.Rd +++ b/man/grouped_dt.Rd @@ -34,4 +34,3 @@ monthly <- group_by(flights_dt, month) summarise(monthly, n = n(), delay = mean(arr_delay)) } } - diff --git a/man/join.tbl_dt.Rd b/man/join.tbl_dt.Rd index 2aed258fa..da1b31ad1 100644 --- a/man/join.tbl_dt.Rd +++ b/man/join.tbl_dt.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/joins.R \name{join.tbl_dt} -\alias{anti_join.data.table} -\alias{full_join.data.table} -\alias{inner_join.data.table} \alias{join.tbl_dt} +\alias{inner_join.data.table} \alias{left_join.data.table} \alias{right_join.data.table} \alias{semi_join.data.table} +\alias{anti_join.data.table} +\alias{full_join.data.table} \title{Join data table tbls.} \usage{ \method{inner_join}{data.table}(x, y, by = NULL, copy = FALSE, ...) @@ -69,4 +69,3 @@ top4 <- semi_join(batting_dt, grid, copy = TRUE) anti_join(batting_dt, person_dt) } } - diff --git a/man/src_local.Rd b/man/src_local.Rd index 94dc8ae5c..cd2fedf49 100644 --- a/man/src_local.Rd +++ b/man/src_local.Rd @@ -14,4 +14,3 @@ which to look for objects.} This is mainly useful for testing, since makes it possible to refer to local and remote tables using exactly the same syntax. } - diff --git a/man/tbl_dt.Rd b/man/tbl_dt.Rd index a16dfd6e1..95f36c5ab 100644 --- a/man/tbl_dt.Rd +++ b/man/tbl_dt.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/tbl-dt.r \name{tbl_dt} -\alias{.datatable.aware} \alias{tbl_dt} +\alias{.datatable.aware} \title{Create a data table tbl.} \usage{ tbl_dt(data, copy = TRUE) @@ -62,4 +62,3 @@ summarise(by_month, delayed = sum(delayed)) ungroup(by_day) } } - From b1200f4dad905990767a5506d841aa805829cc57 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 14:43:06 +0200 Subject: [PATCH 4/8] Register filter() manually --- NAMESPACE | 1 - R/compat-dplyr-0.6.0.R | 33 +++++++++++++++++++++++++++++++++ R/tbl-dt.r | 4 +++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 R/compat-dplyr-0.6.0.R diff --git a/NAMESPACE b/NAMESPACE index 28908c68a..9fc428189 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,7 +18,6 @@ if (utils::packageVersion("dplyr") > "0.5.0") { if (utils::packageVersion("dplyr") > "0.5.0") { importFrom(dplyr,filter) - S3method(filter,data.table) } if (utils::packageVersion("dplyr") > "0.5.0") { diff --git a/R/compat-dplyr-0.6.0.R b/R/compat-dplyr-0.6.0.R new file mode 100644 index 000000000..88784e530 --- /dev/null +++ b/R/compat-dplyr-0.6.0.R @@ -0,0 +1,33 @@ + +.onLoad <- function(libname, pkgname) { + if (utils::packageVersion("dplyr") > "0.5.0") { + register_s3_method("dplyr", "filter", "data.table", filter.data.table) + } + + invisible() +} + +register_s3_method <- function(pkg, generic, class, fun = NULL) { + stopifnot(is.character(pkg), length(pkg) == 1) + envir <- asNamespace(pkg) + + stopifnot(is.character(generic), length(generic) == 1) + stopifnot(is.character(class), length(class) == 1) + if (is.null(fun)) { + fun <- get(paste0(generic, ".", class), envir = parent.frame()) + } + stopifnot(is.function(fun)) + + + if (pkg %in% loadedNamespaces()) { + registerS3method(generic, class, fun, envir = envir) + } + + # Always register hook in case package is later unloaded & reloaded + setHook( + packageEvent(pkg, "onLoad"), + function(...) { + registerS3method(generic, class, fun, envir = envir) + } + ) +} diff --git a/R/tbl-dt.r b/R/tbl-dt.r index ab14cac33..db918f5cc 100644 --- a/R/tbl-dt.r +++ b/R/tbl-dt.r @@ -152,10 +152,12 @@ and_expr <- function(exprs) { left } +# The S3 method is registered manually in .onLoad() to avoid an R CMD +# check warning + #' @rawNamespace #' if (utils::packageVersion("dplyr") > "0.5.0") { #' importFrom(dplyr,filter) -#' S3method(filter,data.table) #' } filter.data.table <- function(.data, ...) { filter_(.data, .dots = lazyeval::lazy_dots(...)) From 460cc326685473daa9e6ba3212d6380059a6a0e5 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 15:01:47 +0200 Subject: [PATCH 5/8] Run revdeps --- .Rbuildignore | 1 + revdep/README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++ revdep/checks.rds | Bin 0 -> 1034 bytes revdep/problems.md | 31 ++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 revdep/README.md create mode 100644 revdep/checks.rds create mode 100644 revdep/problems.md diff --git a/.Rbuildignore b/.Rbuildignore index f5c8873ad..aa4d290a9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^\.travis\.yml$ ^cran-comments\.md$ +^revdep$ diff --git a/revdep/README.md b/revdep/README.md new file mode 100644 index 000000000..4ce56a749 --- /dev/null +++ b/revdep/README.md @@ -0,0 +1,59 @@ +# Setup + +## Platform + +|setting |value | +|:--------|:----------------------------| +|version |R version 3.3.2 (2016-10-31) | +|system |x86_64, darwin13.4.0 | +|ui |X11 | +|language |(EN) | +|collate |en_US.UTF-8 | +|tz |Europe/Brussels | +|date |2017-04-21 | + +## Packages + +|package |* |version |date |source | +|:------------|:--|:----------|:----------|:------------------------| +|covr | |2.2.2 |2017-01-05 |CRAN (R 3.3.2) | +|data.table | |1.10.4 |2017-02-01 |CRAN (R 3.3.2) | +|dplyr | |0.5.0 |2016-06-24 |CRAN (R 3.3.0) | +|dtplyr | |0.0.1.9000 |2017-04-21 |local (hadley/dtplyr@NA) | +|Lahman | |5.0-0 |2016-08-27 |CRAN (R 3.3.0) | +|lazyeval | |0.2.0 |2016-06-12 |CRAN (R 3.3.0) | +|nycflights13 | |0.2.2 |2017-01-27 |CRAN (R 3.3.2) | +|testthat | |1.0.2 |2016-04-23 |CRAN (R 3.3.0) | + +# Check results +4 packages + +## dplyr (0.5.0) +Maintainer: Hadley Wickham +Bug reports: https://github.com/hadley/dplyr/issues + +0 errors | 0 warnings | 0 notes + +## grattan (1.4.1.2) +Maintainer: Hugh Parsonage +Bug reports: https://github.com/HughParsonage/grattan/issues + +0 errors | 0 warnings | 1 note + +``` +checking package dependencies ... NOTE +Package suggested but not available for checking: ‘taxstats’ +``` + +## ndjson (0.2.0) +Maintainer: Bob Rudis +Bug reports: https://gitlab.com/hrbrmstr/ndjson/issues + +0 errors | 0 warnings | 0 notes + +## unpivotr (0.1.0) +Maintainer: Duncan Garmonsway +Bug reports: https://github.com/nacnudus/unpivotr/issues + +0 errors | 0 warnings | 0 notes + diff --git a/revdep/checks.rds b/revdep/checks.rds new file mode 100644 index 0000000000000000000000000000000000000000..75907276a1031922595c82376f6aa2922e0a5cc2 GIT binary patch literal 1034 zcmV+l1oitLiwFP!000001Lap+Z`(E$R(y%mblnDY81}FS0t1R?HiedpaV1+?T=fZR0`OYD9vT0dX z%WAh$b>W0$9?RhE#LKaY|pj(-nOCp z*~RY8XlL*(3W+#RnAgVx>>4`l6VEePovnjI)6`wcM#sP6;}<{LyN2kKgIw^8I!{F| zB~7Iv-h}ub+3vvh!B3~PBFRFCNN{%D9BW@UH&@vky3u$p0<%-@2!4)ro8BuL>k|I1uCD$n z6K0iJ5G6~LNGC_OgY3>WD@-X2z;FIr- zEe~R)GWpnXqC~~{xKMF)4T=&tiIh1tJHBdFgIVIf46R)Wt<`7k+}rvPsSsR9-M!~T zu!KdL?lP{5AZjPv$%u-L7=Ck(B^1h;ahOSoa-P9_9rFw4NbpxQP|_JXHH0~WPD7eG zK}>@)S*DDKbINhu`4gu+GD@}>d~=17pfXRDEDO|#s?7;Wn1V(1M7ulABiNX6p=2}k z48-*oUK&HWUnVkIj>uY_#9Dp(c^<{+hzQ9UxCEpCjWbQ}M-Xt@gcqj)FNLjzDJK#{ zDZ-k8)2pN=+k^YnE5_YB!LwHM6|88UCEx>9M}{DE%0kM5gi3@lMu)$=IM_U@q%x17 zuM`c@I9CX;gvb=~EAAcy_ZHIT9-}vxe<*Sx6;bld<)634YR4?o$?fo2o!*Cl(9fUp zF&e_yl4x(t$NM4=aUxAPZZE+R>RFC2F%}c4gu}vDfXQYcu9re(aht@X@Lrd>+a+W1iu5P&LHneyZDc*m9 zl;3ZM6rIig3@f#OI!)gbi;Jh;{;Ng4$y%>;z9^dh=F#6E%Qw(UI@a620mB1{^R5m6 E00iU-Bme*a literal 0 HcmV?d00001 diff --git a/revdep/problems.md b/revdep/problems.md new file mode 100644 index 000000000..a41e2679d --- /dev/null +++ b/revdep/problems.md @@ -0,0 +1,31 @@ +# Setup + +## Platform + +|setting |value | +|:--------|:----------------------------| +|version |R version 3.3.2 (2016-10-31) | +|system |x86_64, darwin13.4.0 | +|ui |X11 | +|language |(EN) | +|collate |en_US.UTF-8 | +|tz |Europe/Brussels | +|date |2017-04-21 | + +## Packages + +|package |* |version |date |source | +|:------------|:--|:----------|:----------|:------------------------| +|covr | |2.2.2 |2017-01-05 |CRAN (R 3.3.2) | +|data.table | |1.10.4 |2017-02-01 |CRAN (R 3.3.2) | +|dplyr | |0.5.0 |2016-06-24 |CRAN (R 3.3.0) | +|dtplyr | |0.0.1.9000 |2017-04-21 |local (hadley/dtplyr@NA) | +|Lahman | |5.0-0 |2016-08-27 |CRAN (R 3.3.0) | +|lazyeval | |0.2.0 |2016-06-12 |CRAN (R 3.3.0) | +|nycflights13 | |0.2.2 |2017-01-27 |CRAN (R 3.3.2) | +|testthat | |1.0.2 |2016-04-23 |CRAN (R 3.3.0) | + +# Check results +0 packages with problems + + From 165d94edd4d39f1e9cb6d39c55400f2970c9a9a4 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 15:26:06 +0200 Subject: [PATCH 6/8] Bump version --- DESCRIPTION | 5 +++-- NEWS.md | 6 +++++- cran-comments.md | 10 ++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fb06d9772..4437f20c8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,9 @@ Package: dtplyr Title: Data Table Back-End for 'dplyr' -Version: 0.0.1.9000 +Version: 0.0.2 Authors@R: c( - person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), + person("Lionel", "Henry", , "lionel@rstudio.com", role = "cre"), + person("Hadley", "Wickham", , "hadley@rstudio.com", role = "aut"), person("RStudio", role = "cph") ) Description: This implements the data table back-end for 'dplyr' so that you diff --git a/NEWS.md b/NEWS.md index 8c4d8dfed..be2a7420c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# dtplyr 0.0.1.9000 +# dtplyr 0.0.2 + +- This is a compatibility release. It makes dtplyr compatible with + dplyr 0.6.0 in addition to dplyr 0.5.0. + # dtplyr 0.0.1 diff --git a/cran-comments.md b/cran-comments.md index c586c0b7d..4e139d434 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,14 +1,16 @@ ## Test environments -* local OS X install, R 3.3.0 -* ubuntu 12.04 (on travis-ci), R 3.3.1, R 3.2.5, R-devel +* local OS X install, R 3.3.2 +* ubuntu 12.04 (on travis-ci), R 3.3.3, R 3.2.5, R-devel * win-builder (devel) + ## R CMD check results 0 errors | 0 warnings | 1 note -* This is a new release. +* Lionel Henry is taking over as maintainer. + ## Reverse dependencies -This is a new release, so there are no reverse dependencies. +The 4 reverse dependencies were checked and no errors were found. From e599015f275689735e7fe6aee4b67fe9bcc558fb Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 15:36:03 +0200 Subject: [PATCH 7/8] Make codecov quiet --- .Rbuildignore | 1 + codecov.yml | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 codecov.yml diff --git a/.Rbuildignore b/.Rbuildignore index aa4d290a9..305a747e9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,4 @@ ^\.travis\.yml$ ^cran-comments\.md$ ^revdep$ +^codecov\.yml$ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..7568e9eb7 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,12 @@ +comment: false + +coverage: + status: + patch: + default: + target: 0 + threshold: 100 + project: + default: + target: 70 + threshold: 100 From e47cb5cb8e8bb3de25f542c5980dc3784d38aeac Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 21 Apr 2017 23:39:20 +0200 Subject: [PATCH 8/8] Register S3 methods at load time --- NAMESPACE | 97 ------------------------------------------ R/compat-dplyr-0.6.0.R | 67 ++++++++++++++++++++++++++++- R/do.R | 3 -- R/grouped-dt.r | 19 +-------- R/joins.R | 12 ------ R/sample.R | 6 --- R/sets.R | 8 ---- R/tbl-dt.r | 69 ------------------------------ man/join.tbl_dt.Rd | 14 +++--- 9 files changed, 74 insertions(+), 221 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9fc428189..62ce0e849 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,137 +1,40 @@ # Generated by roxygen2: do not edit by hand -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,arrange) - S3method(arrange,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,distinct) - S3method(distinct,data.table) -} - if (utils::packageVersion("dplyr") > "0.5.0") { importFrom(dplyr,do) S3method(do,data.table) } - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,filter) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,group_by) - S3method(group_by,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,mutate) - S3method(mutate,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,rename) - S3method(rename,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,select) - S3method(select,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,slice) - S3method(slice,data.table) -} - -if (utils::packageVersion("dplyr") > "0.5.0") { - importFrom(dplyr,summarise) - S3method(summarise,data.table) -} S3method(all.equal,tbl_dt) -S3method(anti_join,data.table) -S3method(arrange_,data.table) -S3method(arrange_,grouped_dt) -S3method(arrange_,tbl_dt) S3method(as.data.frame,tbl_dt) S3method(as.tbl,data.table) S3method(auto_copy,tbl_dt) S3method(dimnames,tbl_dt) -S3method(distinct_,data.table) -S3method(distinct_,grouped_dt) -S3method(distinct_,tbl_dt) -S3method(do_,data.table) -S3method(do_,grouped_dt) -S3method(do_,tbl_dt) -S3method(filter_,data.table) -S3method(filter_,grouped_dt) -S3method(filter_,tbl_dt) -S3method(full_join,data.table) -S3method(group_by_,data.table) -S3method(group_size,grouped_dt) -S3method(groups,grouped_dt) S3method(groups,tbl_dt) S3method(head,tbl_dt) -S3method(inner_join,data.table) -S3method(left_join,data.table) -S3method(mutate_,data.table) -S3method(mutate_,grouped_dt) -S3method(mutate_,tbl_dt) -S3method(n_groups,grouped_dt) -S3method(print,grouped_dt) S3method(print,tbl_dt) -S3method(rename_,data.table) -S3method(rename_,grouped_dt) -S3method(rename_,tbl_dt) -S3method(right_join,data.table) S3method(same_src,tbl_dt) -S3method(sample_frac,grouped_dt) -S3method(sample_frac,tbl_dt) -S3method(sample_n,grouped_dt) -S3method(sample_n,tbl_dt) -S3method(select_,data.table) -S3method(select_,grouped_dt) -S3method(select_,tbl_dt) -S3method(semi_join,data.table) -S3method(slice_,data.table) -S3method(slice_,grouped_dt) -S3method(slice_,tbl_dt) -S3method(summarise_,data.table) -S3method(summarise_,grouped_dt) -S3method(summarise_,tbl_dt) S3method(tail,tbl_dt) S3method(tbl_vars,tbl_dt) S3method(ungroup,data.table) -S3method(ungroup,grouped_dt) S3method(ungroup,tbl_dt) export(.datatable.aware) export(grouped_dt) export(is.grouped_dt) export(src_dt) export(tbl_dt) -importFrom(dplyr,anti_join) importFrom(dplyr,arrange_) importFrom(dplyr,as.tbl) importFrom(dplyr,auto_copy) importFrom(dplyr,distinct_) importFrom(dplyr,do_) importFrom(dplyr,filter_) -importFrom(dplyr,full_join) importFrom(dplyr,group_by_) -importFrom(dplyr,group_size) importFrom(dplyr,groups) -importFrom(dplyr,inner_join) -importFrom(dplyr,left_join) importFrom(dplyr,mutate_) -importFrom(dplyr,n_groups) importFrom(dplyr,rename_) -importFrom(dplyr,right_join) importFrom(dplyr,same_src) -importFrom(dplyr,sample_frac) -importFrom(dplyr,sample_n) importFrom(dplyr,select_) -importFrom(dplyr,semi_join) importFrom(dplyr,slice_) importFrom(dplyr,summarise_) importFrom(dplyr,tbl_vars) diff --git a/R/compat-dplyr-0.6.0.R b/R/compat-dplyr-0.6.0.R index 88784e530..c1e61eaf6 100644 --- a/R/compat-dplyr-0.6.0.R +++ b/R/compat-dplyr-0.6.0.R @@ -1,9 +1,74 @@ .onLoad <- function(libname, pkgname) { if (utils::packageVersion("dplyr") > "0.5.0") { - register_s3_method("dplyr", "filter", "data.table", filter.data.table) + register_s3_method("dplyr", "do", "data.table") + register_s3_method("dplyr", "group_by", "data.table") + register_s3_method("dplyr", "distinct", "data.table") + register_s3_method("dplyr", "filter", "data.table") + register_s3_method("dplyr", "summarise", "data.table") + register_s3_method("dplyr", "mutate", "data.table") + register_s3_method("dplyr", "arrange", "data.table") + register_s3_method("dplyr", "select", "data.table") + register_s3_method("dplyr", "rename", "data.table") + register_s3_method("dplyr", "slice", "data.table") } + register_s3_method("dplyr", "do_", "data.table") + register_s3_method("dplyr", "do_", "tbl_dt") + + register_s3_method("base", "print", "grouped_dt") + register_s3_method("dplyr", "groups", "grouped_dt") + register_s3_method("dplyr", "group_size", "grouped_dt") + register_s3_method("dplyr", "n_groups", "grouped_dt") + register_s3_method("dplyr", "ungroup", "grouped_dt") + + register_s3_method("dplyr", "group_by_", "data.table") + register_s3_method("dplyr", "do_", "grouped_dt") + register_s3_method("dplyr", "distinct_", "grouped_dt") + + register_s3_method("dplyr", "inner_join", "data.table") + register_s3_method("dplyr", "left_join", "data.table") + register_s3_method("dplyr", "right_join", "data.table") + register_s3_method("dplyr", "semi_join", "data.table") + register_s3_method("dplyr", "anti_join", "data.table") + register_s3_method("dplyr", "full_join", "data.table") + + register_s3_method("dplyr", "sample_n", "tbl_dt") + register_s3_method("dplyr", "sample_n", "grouped_dt") + register_s3_method("dplyr", "sample_frac", "tbl_dt") + register_s3_method("dplyr", "sample_frac", "grouped_dt") + + register_s3_method("dplyr", "distinct_", "data.table") + register_s3_method("dplyr", "distinct_", "tbl_dt") + + register_s3_method("dplyr", "filter_", "grouped_dt") + register_s3_method("dplyr", "filter_", "tbl_dt") + register_s3_method("dplyr", "filter_", "data.table") + + register_s3_method("dplyr", "summarise_", "grouped_dt") + register_s3_method("dplyr", "summarise_", "tbl_dt") + register_s3_method("dplyr", "summarise_", "data.table") + + register_s3_method("dplyr", "mutate_", "grouped_dt") + register_s3_method("dplyr", "mutate_", "tbl_dt") + register_s3_method("dplyr", "mutate_", "data.table") + + register_s3_method("dplyr", "arrange_", "grouped_dt") + register_s3_method("dplyr", "arrange_", "tbl_dt") + register_s3_method("dplyr", "arrange_", "data.table") + + register_s3_method("dplyr", "select_", "grouped_dt") + register_s3_method("dplyr", "select_", "tbl_dt") + register_s3_method("dplyr", "select_", "data.table") + + register_s3_method("dplyr", "rename_", "grouped_dt") + register_s3_method("dplyr", "rename_", "tbl_dt") + register_s3_method("dplyr", "rename_", "data.table") + + register_s3_method("dplyr", "slice_", "grouped_dt") + register_s3_method("dplyr", "slice_", "tbl_dt") + register_s3_method("dplyr", "slice_", "data.table") + invisible() } diff --git a/R/do.R b/R/do.R index a5008b460..5955cbb61 100644 --- a/R/do.R +++ b/R/do.R @@ -8,13 +8,10 @@ do.data.table <- function(.data, ...) { } #' @importFrom dplyr do_ -#' @export do_.data.table <- function(.data, ..., .dots) { out <- do_(as.data.frame(.data), ..., .dots = .dots) data.table::as.data.table(out) } - -#' @export do_.tbl_dt <- function(.data, ..., .dots) { out <- do_(as.data.frame(.data), ..., .dots = .dots) tbl_dt(out) diff --git a/R/grouped-dt.r b/R/grouped-dt.r index d32cc9269..7d83d13f8 100644 --- a/R/grouped-dt.r +++ b/R/grouped-dt.r @@ -37,7 +37,6 @@ grouped_dt <- function(data, vars, copy = TRUE) { data } -#' @export groups.grouped_dt <- function(x) { attr(x, "vars") } @@ -47,7 +46,6 @@ groups.grouped_dt <- function(x) { #' @export is.grouped_dt <- function(x) inherits(x, "grouped_dt") -#' @export print.grouped_dt <- function(x, ..., n = NULL, width = NULL) { cat("Source: local data table ", dplyr::dim_desc(x), "\n", sep = "") cat("Groups: ", commas(deparse_all(dplyr::groups(x))), "\n", sep = "") @@ -56,36 +54,23 @@ print.grouped_dt <- function(x, ..., n = NULL, width = NULL) { invisible(x) } -#' @importFrom dplyr group_size -#' @export group_size.grouped_dt <- function(x) { dplyr::summarise_(x, n = ~n())$n } -#' @importFrom dplyr n_groups -#' @export n_groups.grouped_dt <- function(x) { nrow(dt_subset(x, , quote(list(1)))) } -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,group_by) -#' S3method(group_by,data.table) -#' } +#' @importFrom dplyr group_by_ group_by.data.table <- function(.data, ..., add = FALSE) { group_by_(.data, .dots = lazyeval::lazy_dots(...), add = add) } - -#' @export -#' @importFrom dplyr group_by_ group_by_.data.table <- function(.data, ..., .dots, add = FALSE) { groups <- dplyr::group_by_prepare(.data, ..., .dots = .dots, add = add) grouped_dt(groups$data, groups$groups) } -#' @export -#' @importFrom dplyr ungroup ungroup.grouped_dt <- function(x, ...) { data.table::setattr(x, "vars", NULL) data.table::setattr(x, "class", setdiff(class(x), "grouped_dt")) @@ -95,7 +80,6 @@ ungroup.grouped_dt <- function(x, ...) { # Do --------------------------------------------------------------------------- -#' @export do_.grouped_dt <- function(.data, ..., .dots) { args <- lazyeval::all_dots(.dots, ...) env <- lazyeval::common_env(args) @@ -139,7 +123,6 @@ named_args <- function(args) { # Set operations --------------------------------------------------------------- -#' @export distinct_.grouped_dt <- function(.data, ..., .dots) { groups <- lazyeval::as.lazy_dots(groups(.data)) dist <- distinct_vars(.data, ..., .dots = c(.dots, groups)) diff --git a/R/joins.R b/R/joins.R index b026b6ccd..6c4492c74 100644 --- a/R/joins.R +++ b/R/joins.R @@ -54,23 +54,15 @@ join_dt <- function(op) { # nocov end } -#' @export #' @rdname join.tbl_dt -#' @importFrom dplyr inner_join inner_join.data.table <- join_dt({merge(x, y, by = by$x, allow.cartesian = TRUE)}) -#' @export -#' @importFrom dplyr left_join #' @rdname join.tbl_dt left_join.data.table <- join_dt({merge(x, y, by = by$x, all.x = TRUE, allow.cartesian = TRUE)}) -#' @export -#' @importFrom dplyr right_join #' @rdname join.tbl_dt right_join.data.table <- join_dt(merge(x, y, by = by$x, all.y = TRUE, allow.cartesian = TRUE)) -#' @export -#' @importFrom dplyr semi_join #' @rdname join.tbl_dt semi_join.data.table <- join_dt({ # http://stackoverflow.com/questions/18969420/perform-a-semi-join-with-data-table @@ -79,13 +71,9 @@ semi_join.data.table <- join_dt({ x[w] }) -#' @export -#' @importFrom dplyr anti_join #' @rdname join.tbl_dt anti_join.data.table <- join_dt({x[!y, allow.cartesian = TRUE]}) -#' @export -#' @importFrom dplyr full_join #' @rdname join.tbl_dt # http://stackoverflow.com/a/15170956/946850 full_join.data.table <- join_dt({merge(x, y, by = by$x, all = TRUE, allow.cartesian = TRUE)}) diff --git a/R/sample.R b/R/sample.R index 3912211c6..26f9acd15 100644 --- a/R/sample.R +++ b/R/sample.R @@ -1,11 +1,8 @@ -#' @importFrom dplyr sample_n -#' @export sample_n.tbl_dt <- function(tbl, size, replace = FALSE, weight = NULL, .env = parent.frame()) { tbl_dt(NextMethod()) } -#' @export sample_n.grouped_dt <- function(tbl, size, replace = FALSE, weight = NULL, .env = parent.frame()) { @@ -18,14 +15,11 @@ sample_n.grouped_dt <- function(tbl, size, replace = FALSE, weight = NULL, grouped_dt(tbl[idx], groups(tbl)) } -#' @importFrom dplyr sample_frac -#' @export sample_frac.tbl_dt <- function(tbl, size = 1, replace = FALSE, weight = NULL, .env = parent.frame()) { tbl_dt(NextMethod()) } -#' @export sample_frac.grouped_dt <- function(tbl, size = 1, replace = FALSE, weight = NULL, .env = parent.frame()) { diff --git a/R/sets.R b/R/sets.R index 79050984b..9727b5ecc 100644 --- a/R/sets.R +++ b/R/sets.R @@ -1,16 +1,10 @@ # Set operations --------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,distinct) -#' S3method(distinct,data.table) -#' } distinct.data.table <- function(.data, ..., .keep_all = FALSE) { distinct_(.data, .dots = lazyeval::lazy_dots(...), .keep_all = .keep_all) } -#' @export #' @importFrom dplyr distinct_ distinct_.data.table <- function(.data, ..., .dots, .keep_all = FALSE) { dist <- distinct_vars(.data, ..., .dots = .dots) @@ -27,8 +21,6 @@ distinct_.data.table <- function(.data, ..., .dots, .keep_all = FALSE) { res } - -#' @export distinct_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } diff --git a/R/tbl-dt.r b/R/tbl-dt.r index db918f5cc..39c77177f 100644 --- a/R/tbl-dt.r +++ b/R/tbl-dt.r @@ -155,26 +155,17 @@ and_expr <- function(exprs) { # The S3 method is registered manually in .onLoad() to avoid an R CMD # check warning -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,filter) -#' } filter.data.table <- function(.data, ...) { filter_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr filter_ -#' @export filter_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(NextMethod(), groups(.data), copy = FALSE) } - -#' @export filter_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } - -#' @export filter_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) env <- lazyeval::common_env(dots) @@ -189,27 +180,17 @@ filter_.data.table <- function(.data, ..., .dots) { # Summarise -------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,summarise) -#' S3method(summarise,data.table) -#' } summarise.data.table <- function(.data, ...) { summarise_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr summarise_ -#' @export summarise_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(NextMethod(), drop_last(groups(.data)), copy = FALSE) } - -#' @export summarise_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } - -#' @export summarise_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ..., all_named = TRUE) @@ -219,27 +200,17 @@ summarise_.data.table <- function(.data, ..., .dots) { # Mutate ----------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,mutate) -#' S3method(mutate,data.table) -#' } mutate.data.table <- function(.data, ...) { mutate_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr mutate_ -#' @export mutate_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(NextMethod(), drop_last(groups(.data)), copy = FALSE) } - -#' @export mutate_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } - -#' @export mutate_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ..., all_named = TRUE) names <- lapply(names(dots), as.name) @@ -259,27 +230,17 @@ mutate_.data.table <- function(.data, ..., .dots) { # Arrange ---------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,arrange) -#' S3method(arrange,data.table) -#' } arrange.data.table <- function(.data, ...) { arrange_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr arrange_ -#' @export arrange_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(NextMethod(), groups(.data), copy = FALSE) } - -#' @export arrange_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } - -#' @export arrange_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) @@ -292,17 +253,11 @@ arrange_.data.table <- function(.data, ..., .dots) { # Select ----------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,select) -#' S3method(select,data.table) -#' } select.data.table <- function(.data, ...) { select_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr select_ -#' @export select_.grouped_dt <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) vars <- dplyr::select_vars_(names(.data), dots, @@ -312,8 +267,6 @@ select_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(out, groups(.data), copy = FALSE) } - -#' @export select_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) vars <- dplyr::select_vars_(names(.data), dots) @@ -322,25 +275,17 @@ select_.data.table <- function(.data, ..., .dots) { data.table::setnames(out, names(vars)) out } - -#' @export select_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } # Rename ----------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,rename) -#' S3method(rename,data.table) -#' } rename.data.table <- function(.data, ...) { rename_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr rename_ -#' @export rename_.grouped_dt <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) vars <- dplyr::rename_vars_(names(.data), dots) @@ -350,8 +295,6 @@ rename_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(out, groups(.data), copy = FALSE) } - -#' @export rename_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ...) vars <- dplyr::rename_vars_(names(.data), dots) @@ -360,8 +303,6 @@ rename_.data.table <- function(.data, ..., .dots) { data.table::setnames(out, names(vars)) out } - -#' @export rename_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } @@ -369,27 +310,17 @@ rename_.tbl_dt <- function(.data, ..., .dots) { # Slice ------------------------------------------------------------------- -#' @rawNamespace -#' if (utils::packageVersion("dplyr") > "0.5.0") { -#' importFrom(dplyr,slice) -#' S3method(slice,data.table) -#' } slice.data.table <- function(.data, ...) { slice_(.data, .dots = lazyeval::lazy_dots(...)) } #' @importFrom dplyr slice_ -#' @export slice_.grouped_dt <- function(.data, ..., .dots) { grouped_dt(NextMethod(), groups(.data), copy = FALSE) } - -#' @export slice_.tbl_dt <- function(.data, ..., .dots) { tbl_dt(NextMethod(), copy = FALSE) } - -#' @export slice_.data.table <- function(.data, ..., .dots) { dots <- lazyeval::all_dots(.dots, ..., all_named = TRUE) env <- lazyeval::common_env(dots) diff --git a/man/join.tbl_dt.Rd b/man/join.tbl_dt.Rd index da1b31ad1..fe1ce7bc5 100644 --- a/man/join.tbl_dt.Rd +++ b/man/join.tbl_dt.Rd @@ -26,14 +26,14 @@ \item{x, y}{tbls to join} \item{by}{a character vector of variables to join by. If \code{NULL}, the - default, \code{join} will do a natural join, using all variables with - common names across the two tables. A message lists the variables so - that you can check they're right (to suppress the message, simply - explicitly list the variables that you want to join). +default, \code{*_join()} will do a natural join, using all variables with +common names across the two tables. A message lists the variables so +that you can check they're right (to suppress the message, simply +explicitly list the variables that you want to join). - To join by different variables on x and y use a named vector. - For example, \code{by = c("a" = "b")} will match \code{x.a} to - \code{y.b}.} +To join by different variables on x and y use a named vector. +For example, \code{by = c("a" = "b")} will match \code{x.a} to +\code{y.b}.} \item{copy}{If \code{x} and \code{y} are not from the same data source, and \code{copy} is \code{TRUE}, then \code{y} will be copied into the