从这本书中这里
library(maptools)
s.owin <- as(s.sp, "owin")
class(s.owin)应该可以工作,但是它不工作,并抛出错误'spatstat.options' is not an exported object from 'namespace:spatstat'。spatstat.options()的存在和工作(对我来说)很好:
spatstat.options()
# $areainter.polygonal
# [1] FALSE
#
# $checksegments
# [1] TRUE
# ...我使用了statspat的最新版本:packageVersion("spatstat")给了2.0.1。RStudio不显示任何用于更新过程的依赖包:
x <- installed.packages()
x[grepl("spatstat",x[,"Depends"]),"Package"]
spatstat spatstat.core spatstat.geom spatstat.linnet
"spatstat" "spatstat.core" "spatstat.geom" "spatstat.linnet" p.ppp <- as(p.sp, "ppp") # Create ppp object抛出同样的错误..。
可复制的例子:
library(sp)
grd <- sp::GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as(grd, "SpatialPolygons")
centroids <- sp::coordinates(polys)
x <- centroids[,1]
y <- centroids[,2]
z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
spdf <- sp::SpatialPolygonsDataFrame(polys,
data = data.frame(x=x,
y=y,
z=z,
row.names=row.names(polys)))
library(raster)
plot(spdf)
library(sf)
spsf <- st_as_sf(spdf)
plot(spsf$geometry)
plot(spsf)
library(maptools)
library(spatstat)
s.owin <- as(spdf, "owin") # calls as.owin.SpatialPolygons(from) but to me it is not clear why and I can't debug here...
# Fehler: 'spatstat.options' is not an exported object from 'namespace:spatstat'
spatstat.options()发布于 2021-03-17 15:46:15
尽管RStudio告诉我,所有的软件包都是最新的,但问题仍然存在。解决方案是对R和所有软件包进行全面更新。Windows上的进程
installr::update()运行Rgui.exe (in \R\R-4.0.4\bin\x64)。R_LIBS新的\R\R-4.0.4\库。.libPaths()。(必须有一行.libPaths("C:/R/R-4.0.4/library"),或者只是添加它。)发布于 2021-05-11 00:12:51
只是出现了这个问题,并且可以确认更新包是修复程序。实际上,我无法遵循您的指示(我不太精明),但下面的简单代码起了作用:
首先-重新启动R,以便清除所有预加载的包并进行更新
# list of packages where an update is available
old.packages()
# update all available packages
update.packages()
# update, without prompts for permission/clarification
update.packages(ask = FALSE)https://stackoverflow.com/questions/66674391
复制相似问题