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).
--j
Conditional importFrom (roxygen?)
5 messages · Jonathan Greenberg, Ben Bolker, Duncan Murdoch +1 more
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
Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
On 04/10/2015 10:10 AM, Jonathan Greenberg wrote:
Folks:
[snip snip snip]
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
This has been submitted as an issue at https://github.com/klutometis/roxygen/issues/378 closely related: https://github.com/klutometis/roxygen/issues/371 my current hacky solution to this is to use a Makefile that post-processes the NAMESPACE after it's roxygenized, e.g. search for "getRversion" in https://github.com/glmmTMB/glmmTMB/blob/master/Makefile
On 04/10/2015 7:34 PM, Ben Bolker wrote:
Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
On 04/10/2015 10:10 AM, Jonathan Greenberg wrote:
Folks:
[snip snip snip]
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
This has been submitted as an issue at https://github.com/klutometis/roxygen/issues/378 closely related: https://github.com/klutometis/roxygen/issues/371 my current hacky solution to this is to use a Makefile that post-processes the NAMESPACE after it's roxygenized, e.g. search for "getRversion" in https://github.com/glmmTMB/glmmTMB/blob/master/Makefile
Hadley has the right idea (allow roxygen to specify some uninterpreted text to drop into the NAMESPACE file), but it doesn't go far enough. Really this is a design flaw in roxygen: being able to enter NAMESPACE and help page info in source files is a great feature, but being forced to go all or nothing is a flaw. If base R adds something new to the NAMESPACE or .Rd files (or has some obscure feature that roxygen authors didn't notice), it's really hard for roxygen users to make use of it. A better design would be to allow content from both sources: some manually entered NAMESPACE stuff, and some automatically generated stuff. A really nice design would be to read the manually entered stuff and show (some of?) it in the .R files, but that would be really tricky to get right. I think it would need to be supported by a GUI, it wouldn't be reasonable to expect people to type it all properly in a dumb editor. Maybe Hadley knows someone who has written a GUI? Duncan Murdoch
15 days later
This has been submitted as an issue at https://github.com/klutometis/roxygen/issues/378 closely related: https://github.com/klutometis/roxygen/issues/371 my current hacky solution to this is to use a Makefile that post-processes the NAMESPACE after it's roxygenized, e.g. search for "getRversion" in https://github.com/glmmTMB/glmmTMB/blob/master/Makefile
Hadley has the right idea (allow roxygen to specify some uninterpreted text to drop into the NAMESPACE file), but it doesn't go far enough. Really this is a design flaw in roxygen: being able to enter NAMESPACE and help page info in source files is a great feature, but being forced to go all or nothing is a flaw. If base R adds something new to the NAMESPACE or .Rd files (or has some obscure feature that roxygen authors didn't notice), it's really hard for roxygen users to make use of it.
It should much easier in the dev version - you can use @rawRd and @rawNamespace to insert literal Rd code and NAMESPACE directives without any interpretation by roxygen.
A better design would be to allow content from both sources: some manually entered NAMESPACE stuff, and some automatically generated stuff.
I think you can now mostly do this - it might be possible to do more intermingling, but it starts to get really hard to figure out which is the authoritative version and to respond usefully to conflicts. I'm not opposed to the idea, but it's a hard problem and unfortunately not very high on my priority list.
A really nice design would be to read the manually entered stuff and show (some of?) it in the .R files, but that would be really tricky to get right. I think it would need to be supported by a GUI, it wouldn't be reasonable to expect people to type it all properly in a dumb editor. Maybe Hadley knows someone who has written a GUI?
Nope, sorry :P More seriously, again I think it would be possible, and it's not that I'm opposed to it, but realistically, it's unlikely to ever get high enough up our priority list to get implemented. Hadley