[Rd] Conditional importFrom (roxygen?)
Duncan Murdoch
murdoch.duncan at gmail.com
Sun Oct 4 18:23:09 CEST 2015
On 04/10/2015 10:10 AM, Jonathan Greenberg wrote:
> Folks:
>
> I am getting a build failure when I:
> #' @importFrom utils shortPathName
>
> which roxygenizes it to the NAMESPACE.
>
> I suspect this is because this particular function is Windows-only, but I'm
> a bit confused how I should "properly" importFrom a function like this so
> it doesn't cause a build failure, but I don't get a note in my R CMD CHECK
> if I DON'T have it:
>
> gdal_setInstallation : correctPath: no visible global function
> definition for 'shortPathName'
> gdalinfo: no visible global function definition for 'glob2rx'
> gdallocationinfo: no visible global function definition for
> 'write.table'
> gdaltransform: no visible global function definition for 'write.table'
> get_subdatasets: no visible global function definition for 'glob2rx'
> mosaic_rasters: no visible global function definition for 'write.table'
> Undefined global functions or variables:
> glob2rx shortPathName write.table
> Consider adding
> importFrom("utils", "glob2rx", "shortPathName", "write.table")
> to your NAMESPACE.
>
> I'll note my function actually first checks to see what OS is running, and
> doesn't use this function on non-Windows machines, so having this function
> does not cause any actual errors:
>
> ...
>
> if (.Platform$OS.type=="windows")
>
> {
>
> x <- shortPathName(x)
>
> } else
>
> {
>
> x <- path.expand(x)
>
> }
>
>
> ...
>
> Is there a way to do a conditional importFrom based on the OS? Or can I
> safely ignore this (I'm trying to submit to CRAN).
>
Yes, you can put conditionals into the NAMESPACE file. Apparently
roxygen2 doesn't support this feature, so you'll have to do it by hand.
Duncan Murdoch
More information about the R-devel
mailing list