From 216bbc7e2b21791509ab3254fd0a519e621e8d74 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Wed, 21 Aug 2024 09:32:35 -0700 Subject: [PATCH] Tweak for consistency --- dependencies-in-practice.Rmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dependencies-in-practice.Rmd b/dependencies-in-practice.Rmd index fa465fcee..3657a5290 100644 --- a/dependencies-in-practice.Rmd +++ b/dependencies-in-practice.Rmd @@ -676,10 +676,10 @@ export(count) ... ``` -Now imagine that your package implements a method for `count()` for a class you "own" (not `data.frame`) but a generic that you "don't own". +Now imagine that your package implements a method for `count()` for a class you "own" (not `data.frame`). A good example is the dbplyr package, which implements dplyr's `count()` generic for dbplyr's `tbl_lazy` class. -In this case, `@export` will not work because it assumes the `count()` generic is included or imported in the dbplyr NAMESPACE, so instead we need to use `@exportS3Method`, providing the precise generic that we're providing a method for. +In this case, `@export` will not work because it assumes the `count()` generic is included or imported in the dbplyr `NAMESPACE`, so instead we need to use `@exportS3Method`, providing the precise generic that we're providing a method for. ```{r} #| eval: false @@ -693,9 +693,9 @@ In `NAMESPACE`, we have: S3method(dplyr::count,tbl_lazy) ``` -This also works for generics for packages that are suggested dependencies, e.g. where the glue package implements a method for testthat's `compare()` generic: glue lists testthat as only a suggested dependency, so (as of R 3.6.0) R will conditionally register the method `compare.glue()` when both the testthat and the glue packages are loaded. +This also works for generics from packages that are suggested dependencies, e.g. where the glue package implements a method for testthat's `compare()` generic: glue lists testthat as only a suggested dependency, so (as of R 3.6.0) R will conditionally register the method `compare.glue()` when both the testthat and the glue packages are loaded. -dbplyr also provides methods for various generics provided by the base package, such as `dim()` and `names()` - in this case, we can still use `@export` since the generics are available in the package NAMESPACE. +dbplyr also provides methods for various generics provided by the base package, such as `dim()` and `names()` - in this case, we can still use `@export` since the generics are available in the package `NAMESPACE`. In `dbplyr/R/tbl_lazy.R`, we have: