The following roxygen2 header imports the method you need:
#' Hello
#' @export
#' @importFrom rgeos coerce
hello <- function() {
a = matrix(1, 2,2)
as(a, "gpc.poly")
}
This is a bit strange: for the as
function to function correctly
needs the function coerce
of the rgeos
package. Remember that the package must be correctly 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