[R-pkg-devel] Acknowledging small functions from another package

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Thu May 4 15:27:04 CEST 2023


   In fact Martin Maechler added this in 2021:

https://github.com/wch/r-source/blob/trunk/src/library/utils/R/str.R#L19-L21

## A pearl from ggplot2 et al.  NB: often needs '(.)' :   <lhs> %||% ( 
<rhs> )
## *not exported* [should rather be in 'base' than exported here]
`%||%` <- function(L,R) if(is.null(L)) R else L


On 2023-05-04 5:59 a.m., David Hugh-Jones wrote:
> Thank you both. This sounds sensible. Yeah, add my vote for `base::%||%`!!
> 
> 
> David
> 
> 
> On Thu, 4 May 2023 at 10:00, Duncan Murdoch <murdoch.duncan using gmail.com>
> wrote:
> 
>> On 04/05/2023 4:53 a.m., Ivan Krylov wrote:
>>> On Thu, 4 May 2023 09:21:17 +0100
>>> David Hugh-Jones <davidhughjones using gmail.com> wrote:
>>>
>>>> One of my packages copy-pasted some small functions (stuff like
>>>> `%||%` for is.null) from ggplot2. (Both packages are MIT-licensed.)
>>>>
>>>> What is an appropriate way to acknowledge this in the DESCRIPTION
>>>> Author: or Authors using R section?
>>>
>>> One way would be to mention Hadley Wickham:
>>>
>> https://github.com/tidyverse/ggplot2/commit/ef2f944863a0db8841bf628e9eb4a9faef5049e6#diff-8f53135445ab98749043fa52e438346bb9acae8e0185aa95f186d0aa021bb7e0
>>> (`git blame` will also tell you that he later moved this function to a
>>> different file).
>>>
>>> I think that person('ggplot2 authors', role = 'cph', comment = 'The
>>> %||% operator') is also fine, just like e.g. unitizer package mentions
>>> the code taken from R itself.
>>>
>>> You can also find this operator in multiple base R packages, currently
>>> unexported (maybe some day...). They mention in the comments that the
>>> operator is adapted from ggplot2.
>>
>> I'd probably use role = "ctb" instead for "ggplot2 authors", and include
>> Posit PBC as a copyright holder (as ggplot2 does).  Presumably you or
>> others are also copyright holders for your package and should also have
>> role = "cph" added so it doesn't give the impression that Posit owns
>> everything.
>>
>> Duncan Murdoch
>>
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
 > E-mail is sent at my convenience; I don't expect replies outside of 
working hours.



More information about the R-package-devel mailing list