[R] [R-sig-Geo] raster::levels() not working in packaged function.

nevil amos nev||@@mo@ @end|ng |rom gm@||@com
Sun Nov 1 00:01:57 CET 2020


Many thanks,

That worked, since the NAMESPACE file incudes a warning about editing it
directly I ysed the reoygen tag in the fucntion script
#' @import raster.

On Sun, 1 Nov 2020 at 00:18, Marcelino de la Cruz Rot <
marcelino.delacruz using urjc.es> wrote:

> Maybe including
>
> import(raster)
>
> or
>
> importFrom("raster", "levels")
>
> in the package NAMESPACE would help.
>
> Cheers,
>
> Marcelino
>
> El 31/10/2020 a las 13:24, nevil amos escribió:
> > Apologies, I cannot see how to make a rero for this issue.
> >
> > I have a function that uses levels(r) tor return the RAT of a raster "r"
> > when the function is sourced from a script
> > source(".\R\function.r")
> > it works fine.
> > when the function is built into a package and sourced from there
> > library(mypackage) using the same script file to make the package
> > levels(r)[[1]]
> > the same line throws an error, as levels(myraster returns NULL
> >
> > If I modify the script to include the raster namespace:
> > raster::levels(r)[[1]]
> > Then I get the error
> >   Error: 'levels<-' is not an exported object from 'namespace:raster'
> >
> >
> > I have also tried just using levels(r) and putting raster as a depends
> > rather than an import in the DESCRIPTION file for the package, this does
> > not solve the error.
> >
> >
> > Any suggestions on how to overcome the problem?
> >
> > many thanks
> >
> > Nevil Amos
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > .
>
>
> --
> Marcelino de la Cruz Rot
> Depto. de Biología y Geología
> Física y Química Inorgánica
> Universidad Rey Juan Carlos
> Móstoles España
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list