The following roxygen2 header correctly imports the method you need:
#' Hello
#' @export
#' @importFrom rgeos coerce
hello <- function() {
a = matrix(1, 2,2)
as(a, "gpc.poly")
}
This is a little strange: for the function as
function properly it
precise function coerce
package rgeos
. Remember that the package needs to be properly installed.
The package build returned this:
==> devtools::document(roclets=c('rd', 'collate', 'namespace'))
Updating test documentation
Loading test
Writing NAMESPACE
Documentation completed
==> R CMD INSTALL --no-multiarch --with-keep.source test
* installing to library ‘/home/dfalbel/R/x86_64-pc-linux-gnu-library/3.2’
* installing *source* package ‘test’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (test)
And the function worked correctly:
Restarting R session...
> library(test)
> hello()
GPC Polygon
Num. Contours: 1
Num. Vertices: 2
BBox (X): 1 --> 1
BBox (Y): 1 --> 1