Skip to content

Commit

Permalink
replace checks for class with inherits
Browse files Browse the repository at this point in the history
  • Loading branch information
mkborregaard committed Mar 31, 2023
1 parent c996aeb commit a899894
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/Prepare_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nodiv_data <- function(phylo, commatrix, coords, proj4string_in = CRS(as.charact
{
type = match.arg(type)

if (!(class(phylo) == "phylo")) stop ("phylo must be a phylogeny in the ape format")
if (!(inherits(phylo, "phylo"))) stop ("phylo must be a phylogeny in the ape format")

if (!inherits(commatrix, "distrib_data"))
{
Expand Down Expand Up @@ -107,7 +107,7 @@ distrib_data <- function(commatrix, coords = NULL, proj4string_in = CRS(as.chara


## Testing that input objects are all right
if (class(coords)[1] == "SpatialPointsDataFrame" | class(coords)[1] == "SpatialPixelsDataFrame")
if (inherits(coords, "SpatialPointsDataFrame") | inherits(coords, "SpatialPixelsDataFrame"))
if (!all.equal(proj4string_in,coords@proj4string))
{
proj4string_in <- proj4string(coords)
Expand Down Expand Up @@ -140,7 +140,7 @@ distrib_data <- function(commatrix, coords = NULL, proj4string_in = CRS(as.chara
message("Transforming coords to spatial points")
if (is.data.frame(coords)) coords <- toSpatialPoints(coords,proj4string_in, commatrix, type)

if (class(coords)[1] == "SpatialPixelsDataFrame") type <- "grid" else if (class(coords)[1] == "SpatialPointsDataFrame") type <- "points" else stop("coords must be a data.frame of coordinates or an sp data.frame object")
if (inherits(coords, "SpatialPixelsDataFrame")) type <- "grid" else if (inherits(coords, "SpatialPointsDataFrame")) type <- "points" else stop("coords must be a data.frame of coordinates or an sp data.frame object")


## making sure that the points and the commatrix fit
Expand Down

0 comments on commit a899894

Please sign in to comment.