[R-pkg-devel] package with datasets requiring sp

Andrew Simmons @kw@|mmo @end|ng |rom gm@||@com
Wed Jan 19 16:50:11 CET 2022


It seems like I did misunderstand. What I'd suggest instead is adding:

importClassesFrom(sp, ...)
importMethodsFrom(sp, ...)

in your NAMESPACE file, and then put the class names and method names that
you need. This is (probably) the best solution; it imports only the things
you absolutely need from sp, while making sp a hard dependency (your
package namespace cannot by load without the sp namespace also loaded).

On Tue, Jan 18, 2022, 04:03 Aurélie Siberchicot <
aurelie.siberchicot using univ-lyon1.fr> wrote:

> Thank you Andrew !
> I think I didn't explain my context correctly.
> I'm not importing datasets from 'sp'. I have datasets that are built from
> S4 objects of sp.
> In pratical terms, I don't import anything from 'sp' but I need 'sp' for
> my datasets to exist.
>
> Cheers.
> Aurélie.
>
>
> Le 17/01/2022 à 17:24, Andrew Simmons a écrit :
>
> If a package is declared in Imports, it means that there must be some kind
> of import expression in the NAMESPACE file. For example:
>
> import(sp) # imports the whole sp package, probably NOT what you want
> importFrom(sp, Polygon)  # import object Polygon from sp namespace
>
> Theoretically, your import statement could import any of the sp namespace
> objects, but it probably makes far more sense to import the datasets from
> sp that you're using
>
> On Mon, Jan 17, 2022, 11:11 Aurélie Siberchicot <
> aurelie.siberchicot using univ-lyon1.fr> wrote:
>
>> Hi,
>>
>> I maintain the 'ade4' package which contains data with S4 objects from
>> the package 'sp'.
>> Some functions of the 'sp' package are also used in examples in some Rd
>> files (using the code -- if(requireNamespace("sp", quietly = TRUE)) {}
>> --).
>> In February 2020, I moved the 'sp' package from 'Suggests' to 'Imports'
>> according to an email received from Brian Ripley, because "At least one
>> of the datasets cannot be loaded without a package declared in Suggests:
>> -- typically this is because it loads a namespace defining S4 classes,
>> and such imports should be declared in Imports or (as Matrix does) use a
>> .R wrapper."
>>
>> For a few months, I have had the following NOTE:
>> * checking dependencies in R code ... NOTE
>> Namespace in Imports field not imported from: ‘sp’
>> All declared Imports should be used.
>>
>> In 'Writing R Extensions', I found: "Packages needed to use datasets
>> from the package should be in ‘Imports’: this includes those needed to
>> define S4 classes used."
>>
>> Moving back 'sp' in 'Suggests' seems to solves the NOTE but is contrary
>> to the recommendations of 'Writing R Extensions' and Brian Ripley.
>> I'm a bit confused to solve this note and the best way to declare the
>> dependency of 'ade4' to 'sp'.
>> Is anyone in my situation? Does anyone have any advice?
>>
>> Thanks in advande for any help.
>> Cheers.
>> Aurélie.
>>
>>
>>
>>
>>
>> --
>> Aurélie SIBERCHICOT
>> Ingénieure en Ingénierie Logicielle
>> 04 72 44 85 98 - aurelie.siberchicot using univ-lyon1.fr
>>
>> Laboratoire Biométrie et Biologie Evolutive - UMR CNRS 5558
>> Université Claude Bernard - Lyon 1
>> Bâtiment Grégor Mendel, 43 boulevard du 11 novembre 1918
>> 69622 Villeurbanne cedex
>>
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>
>
> --
> Aurélie SIBERCHICOT
> Ingénieure en Ingénierie Logicielle
> 04 72 44 85 98 - aurelie.siberchicot using univ-lyon1.fr
>
> Laboratoire Biométrie et Biologie Evolutive - UMR CNRS 5558
> Université Claude Bernard - Lyon 1
> Bâtiment Grégor Mendel, 43 boulevard du 11 novembre 1918
> 69622 Villeurbanne cedex
>
>
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list