我正在尝试使用bioclim方法在R的“ dismo”程序包中进行物种分布建模。
安装必要的程序包然后加载它之后,一切似乎都很正常。
,“ dismo”软件包将出现在Rstudio的软件包框中,并且也已选中。
#install packages
install.packages("dismo")
install.packages("maptools")
install.packages("rgdal")
install.packages("raster")
install.packages("sp")
#Loading Libraries
library("sp")
library("raster")
library("maptools")
library("rgdal")
library("dismo")
但是,在尝试运行bioclim方法后,出现以下错误。
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘bioclim’ for signature ‘"character", "data.frame"’
当我尝试检查方法的“帮助”部分时,出现以下错误:
Error in find.package(if (is.null(package)) loadedNamespaces() else package, :
there is no package called ‘package:dismo’
这是我使用的完整代码
setwd("D:/Riset/MaxentSelaginella/newpaperproject_part2/MakalahVI/Workspace_R")
dir.create(path="data2")
dir.create(path="output2")
#install additional R Packages
install.packages("dismo")
install.packages("maptools")
install.packages("rgdal")
install.packages("raster")
install.packages("sp")
#Loading Libraries
library("sp")
library("raster")
library("maptools")
library("rgdal")
library("dismo")
#input Occurrence data & clim variables
obs.data <- read.csv(file = "data3/Selaginella_plana.csv")
bio.var <- list.files(path = "data3/asc/", pattern = ".asc")
# Determine geographic extent of our data
max.lat <- ceiling(max(27))
min.lat <- floor(min(-11))
max.lon <- ceiling(max(122))
min.lon <- floor(min(120))
geographic.extent <- extent(x = c(min.lon, max.lon, min.lat, max.lat))
# Load the data to use for our base map
data(wrld_simpl)
# Plot the base map
plot(wrld_simpl,
xlim = c(min.lon, max.lon),
ylim = c(min.lat, max.lat),
axes = TRUE,
col = "grey95")
# Add the points for individual observation
points(x = obs.data$longitude,
y = obs.data$latitude,
col = "olivedrab",
pch = 20,
cex = 0.75)
# And draw a little box around the graph
box()
# Build species distribution model
bc.model <- dismo::bioclim(x = bio.var, p = obs.data)
有人可以解释为什么会出现这种错误以及如何解决该错误吗?提前谢谢〜