problem executing bioclim method in dismo package in R

585 views Asked by At

I'm trying to run species distribution modelling using bioclim method in "dismo" package in R.

after installing the necessary package and then load it, everything seems normal.

and the "dismo" package appears in the package box of Rstudio, it's also checked.

#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")

However, after I tried to run the bioclim method I got the following error.

Error in (function (classes, fdef, mtable)  : unable to find an inherited method for function ‘bioclim’ for signature ‘"character", "data.frame"’

when I tried to check the "help" section of the method, I got the following error :

Error in find.package(if (is.null(package)) loadedNamespaces() else package,  : 
there is no package called ‘package:dismo’

here are the full code I used

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)

Could anybody explain why such error appears and how to fix that? Thanks in advance~

0

There are 0 answers