I have experiencing a weird problem with the 'plot' function of the 'raster' package.
library(raster)
ras <- raster(ncol=10, nrow=10)
EDIT
values(ras) <- runif(ncell(ras))
END EDIT
plot(ras)
Erreur dans as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
For what I have read on the net, this error depends on the user, and probably depends on the loaded packages. In my case, the problem comes from the fact that r uses the standard 'plot' method from the 'graphics' package, when it should use the specific 'raster' method since 'ras' is a rasterLayer object. However, for a reason I do not understand, 'plot' is not imported in the 'raster' namespace, while all the other functions are.
> raster::plot
Erreur : 'plot' n'est pas un objet exporté depuis 'namespace:raster'
To be compared with :
raster::persp
standardGeneric for "persp" defined from package "graphics"
function (x, ...)
standardGeneric("persp")
<environment: 0x0cd9eb80>
Methods may be defined for arguments: x
Use showMethods("persp") for currently available ones.
Since I do not completely understand how namespaces behave, I am looking for your help ! Is this kind of situation familiar for you, and do you have a way to solve it ? In the meantime, do you know a function to display the content of a namespace (so I could check the content of the raster namespace step by step) ?
PS: I am using R 2.15.2 with RStudio, many packages loaded but all are up to date.
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=French_Belgium.1252 LC_CTYPE=French_Belgium.1252 LC_MONETARY=French_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=French_Belgium.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] raster_2.0-41 sp_1.0-5
loaded via a namespace (and not attached):
[1] grid_2.15.0 hexbin_1.26.0 intervals_0.13.3 lattice_0.20-6 rgdal_0.8-4 spacetime_1.0-3 spam_0.29-2 tools_2.15.0
[9] xts_0.9-2 zoo_1.7-9
Thanks you,
François