[R-pkg-devel] sf subsetting with square bracket

Berry Boessenkool berryboe@@enkoo| @end|ng |rom hotm@||@com
Sun Feb 3 23:21:03 CET 2019


Hi,
my package in question can only be online next week, but here's a script for a MWE:
https://gist.github.com/brry/7728b9b2d35afad7f1fc5978c3315009
The script uses devtools and osmplotr to
- create a package with a bare minimum dummy function
- run the code showing the problem
- create a solution using the ::: import
- clean up, removing the package and the folder for it

btw:  sf 0.7.2,   R 3.4.3,   x86_64-w64-mingw32/x64 (64-bit)

Kind regards,
Berry


________________________________
From: Duncan Murdoch <murdoch.duncan using gmail.com>
Sent: Sunday, February 3, 2019 21:41
To: Berry Boessenkool; R package devel
Subject: Re: [R-pkg-devel] sf subsetting with square bracket

On 03/02/2019 3:02 p.m., Berry Boessenkool wrote:
>
> Hi,
>
> if sf is not loaded, subsetting an sf object with square brackets loses the sf class in the geometry column:
> sfobj[somerows,]
> For usage in a package, I do not want to call library(sf) first.
>
> [ is an S3 method in sf:
> https://github.com/r-spatial/sf/blob/master/NAMESPACE#L6
> https://github.com/r-spatial/sf/blob/master/R/sf.R#L299
>
> In my package (with an sf object from osmplotr), using
> sf:::"[.sf"(obj, somerows, allcolumns)
> works fine, but of course Rcmd check complains about the Unexported object imported by a ':::' call.
>
> How can I use the sf [ method without completely loading sf?
> (and also without depending on dplyr::select)
>
> I guess I'm missing some really clever method import.
> Can someone point me in the right direction?

You need to show us something reproducible if you want help.  Is your
package on Github or some other public repository?

Duncan Murdoch

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list