Closed Laurentlsantos closed 5 years ago
Maybe reinstall packages raster and spacetime?
Hi Edzer! Thanks for your response. I have uninstalled and installed gstat and spacetime many times and It doesn t work to knit the chapter on Bookmark. If I run the code on the "run current chunk" then it runs well. So the code is fine. But when I try to knit the chapter, there is still a problem with the package "gstat". I have installed manually with : install.packages("gstat",dependencies=T) , and then I try library (gstat) and I get the following error: "Error: package or namespace load failed for ‘gstat’: package slot missing from signature for generic ‘coerce’ and classes STFDF, RasterBrick cannot use with duplicate class names (the package may need to be re-installed)"
Please give me a hint.
What is your sessionInfo()
?
"package slot missing from signature for generic ‘coerce’ and classes STFDF, RasterBrick"
Wouldn't that suggest some wrong input objects?
Hi there! running sessionInfo() I come to know that gstat is not loaded via a namespace. But the package does appear in the pane "packages" (gstat version 2.0-2).
Regarding the code and objects, they are fine since the analysis has been carried on normally on the console. As I mentioned, the problem relates to rendering a chapter with Bookdown.
Please share the output of your sessionInfo() here, and also report the rstudio version you are using.
R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] raster_2.9-5 sp_1.3-1
loaded via a namespace (and not attached):
[1] zoo_1.8-6 tidyselect_0.2.5 xfun_0.7 purrr_0.3.2
[5] urca_1.3-0 lattice_0.20-38 colorspace_1.4-1 htmltools_0.3.6
[9] viridisLite_0.3.0 yaml_2.2.0 plotly_4.9.0 rlang_0.3.4
[13] pillar_1.4.1 glue_1.3.1 forecast_8.7 TTR_0.23-4
[17] plyr_1.8.4 quantmod_0.4-14 timeDate_3043.102 munsell_0.5.0
[21] gtable_0.3.0 htmlwidgets_1.3 codetools_0.2-16 evaluate_0.14
[25] knitr_1.23 tseries_0.10-47 lmtest_0.9-37 parallel_3.6.0
[29] curl_3.3 xts_0.11-2 Rcpp_1.0.1 scales_1.0.0
[33] jsonlite_1.6 fracdiff_1.4-2 ggplot2_3.1.1 digest_0.6.19
[37] bookdown_0.11 dplyr_0.8.1 grid_3.6.0 quadprog_1.5-7
[41] tools_3.6.0 magrittr_1.5 lazyeval_0.2.2 tibble_2.1.3
[45] crayon_1.3.4 tidyr_0.8.3 pkgconfig_2.0.2 data.table_1.12.2
[49] assertthat_0.2.1 rmarkdown_1.13 httr_1.4.0 rstudioapi_0.10
[53] R6_2.4.0 intervals_0.15.1 nnet_7.3-12 nlme_3.1-139
[57] compiler_3.6.0
Please correct with gstat loaded.
R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] raster_2.9-5 sp_1.3-1
loaded via a namespace (and not attached):
[1] zoo_1.8-6 tidyselect_0.2.5 xfun_0.7 purrr_0.3.2
[5] urca_1.3-0 lattice_0.20-38 colorspace_1.4-1 htmltools_0.3.6
[9] viridisLite_0.3.0 yaml_2.2.0 plotly_4.9.0 rlang_0.3.4
[13] pillar_1.4.1 glue_1.3.1 forecast_8.7 TTR_0.23-4
[17] plyr_1.8.4 quantmod_0.4-14 timeDate_3043.102 munsell_0.5.0
[21] gtable_0.3.0 htmlwidgets_1.3 codetools_0.2-16 evaluate_0.14
[25] knitr_1.23 tseries_0.10-47 lmtest_0.9-37 parallel_3.6.0
[29] curl_3.3 xts_0.11-2 Rcpp_1.0.1 scales_1.0.0
[33] jsonlite_1.6 fracdiff_1.4-2 ggplot2_3.1.1 digest_0.6.19
[37] bookdown_0.11 dplyr_0.8.1 grid_3.6.0 quadprog_1.5-7
[41] tools_3.6.0 magrittr_1.5 lazyeval_0.2.2 tibble_2.1.3
[45] crayon_1.3.4 tidyr_0.8.3 pkgconfig_2.0.2 data.table_1.12.2
[49] assertthat_0.2.1 rmarkdown_1.13 httr_1.4.0 rstudioapi_0.10
[53] R6_2.4.0 intervals_0.15.1 nnet_7.3-12 nlme_3.1-139
[57] compiler_3.6.0
package ‘gstat’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in C:\Users\Laurent\AppData\Local\Temp\RtmpWIr3Ez\downloaded_packages
sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] raster_2.9-5 sp_1.3-1
loaded via a namespace (and not attached):
[1] zoo_1.8-6 tidyselect_0.2.5 xfun_0.7 purrr_0.3.2
[5] urca_1.3-0 lattice_0.20-38 colorspace_1.4-1 htmltools_0.3.6
[9] viridisLite_0.3.0 yaml_2.2.0 plotly_4.9.0 rlang_0.3.4
[13] pillar_1.4.1 glue_1.3.1 forecast_8.7 TTR_0.23-4
[17] plyr_1.8.4 quantmod_0.4-14 timeDate_3043.102 munsell_0.5.0
[21] gtable_0.3.0 htmlwidgets_1.3 codetools_0.2-16 evaluate_0.14
[25] knitr_1.23 tseries_0.10-47 lmtest_0.9-37 parallel_3.6.0
[29] curl_3.3 xts_0.11-2 Rcpp_1.0.1 scales_1.0.0
[33] jsonlite_1.6 fracdiff_1.4-2 ggplot2_3.1.1 digest_0.6.19
[37] bookdown_0.11 dplyr_0.8.1 grid_3.6.0 quadprog_1.5-7
[41] tools_3.6.0 magrittr_1.5 lazyeval_0.2.2 tibble_2.1.3
[45] crayon_1.3.4 tidyr_0.8.3 pkgconfig_2.0.2 data.table_1.12.2
[49] assertthat_0.2.1 rmarkdown_1.13 httr_1.4.0 rstudioapi_0.10
[53] R6_2.4.0 intervals_0.15.1 nnet_7.3-12 nlme_3.1-139
[57] compiler_3.6.0
Yes, but what is sessionInfo() after you give a library(gstat)
.
library(gstat) Error: package or namespace load failed for ‘gstat’: package slot missing from signature for generic ‘coerce’ and classes STFDF, RasterBrick cannot use with duplicate class names (the package may need to be re-installed)
I do install gstat but I am unable to load it
Try loading it in an R session that didn't load anything (also no .RData) on startup.
In a completely blank project it works: sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] gstat_2.0-2
loaded via a namespace (and not attached):
[1] zoo_1.8-6 compiler_3.6.0 tools_3.6.0 xts_0.11-2
[5] sp_1.3-1 spacetime_1.2-2 yaml_2.2.0 grid_3.6.0
[9] FNN_1.1.3 intervals_0.15.1 lattice_0.20-38
So you can start debugging there: add packages additionally needed one by one, then run your script, and report where and when things break.
it works now.
Thank you very much for your support!
What package was causing the issue as i'm also having the same problem
Hi Andrew. I followed the recommendation and I debugged the code from zero. I do not remember where the problem comes from.
Hi,
I had the same problem after downloading mapview and a few other spatial packages, it looks like now gstat and raster no longer can be loaded together. I just saved the gstat outputs as data frames and reloaded R with raster to continue working.
My solution was just to unload gstat
after i used it with: detach("package:gstat", unload=TRUE)
My solution was just to unload
gstat
after i used it with:detach("package:gstat", unload=TRUE)
This solution works, but I found I also need to unload raster from the namespace on R's startup. unloadNamespace('raster')
I also found that calling gstat explicitly (i.e. gstat::fun) works while having raster loaded. Example with some polygon data:
cent <- subset(lakeobjects, perm == 1) %>%
st_geometry %>%
st_centroid %>%
st_sfc %>%
st_sf
# cent <- st_sf(st_sfc(st_centroid(st_geometry(lakeobjects[, ]))))
cent$area <- subset(lakeobjects, perm == 1)$area
v <- gstat::variogram(area ~ 1, cent)
fv <- gstat::fit.variogram(v, gstat::vgm("Exp"), fit.method = 6)
> fv
model psill range
1 Nug 113270981145 0.0
2 Exp 341807678285 43608.2
I did have the same problem. After
unloadNamespace('raster') unloadNamespace('terra')
I was able to load gstat.
Dear all,
I am working with Bookdown and I got a problem with the package "gstat".
When I try to knit the chapter, there is a message stating: "package or namespace load failed for 'gstat': package slot missing from signature for generic 'coerce' and classes STFDF, RasterBrick cannot use with duplicate class names".
I have already checked that the package is indeed installed, so I do not know what is wrong.
Thank you for any help in advance.