存在-不存在矩阵
Presence-absence matrix
我正在尝试根据 letsR
包和 lets.presab.points()
函数中的示例代码生成存在-不存在矩阵网格。
示例代码:
species <- c(rep("sp1", 100), rep("sp2", 100),
rep("sp3", 100), rep("sp4", 100))
x <- runif(400, min = -69, max = -51)
y <- runif(400, min = -23, max = -4)
xy <- cbind(x, y)
PAM <- lets.presab.points(xy, species, xmn = -93, xmx = -29,
ymn = -57, ymx = 15)
summary(PAM)
我的代码:
records <- read.csv("directoryremovedforprivacy.csv")
x <- records$lon
y <- records$lat
xy <- cbind(x, y)
PAM2 <- lets.presab.points(xy, records, xmn = -11.5, xmx = 3,
ymn = 49, ymx = 61)
summary(PAM2)
但是我收到以下错误:
Error in xy[pos, , drop = FALSE] : (subscript) logical subscript too long
In addition: Warning message:
In xtfrm.data.frame(x) : cannot xtfrm data frames
> summary(PAM2)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'object' in selecting a method for function 'summary': object 'PAM2' not found
根据错误消息,问题可能出在 lets.presab.points
中的 records
。它需要一个物种列表,但你正试图给它一个数据框。因此,在您的示例代码中, species
是一个字符向量,因此它也需要与您的代码具有相同的格式。所以,你可能需要做这样的事情(虽然我不确定你的 records
数据的格式是什么):
library(letsR)
PAM2 <- lets.presab.points(xy, records$species, xmn = -11.5, xmx = 3,
ymn = 49, ymx = 61)
species
需要与 xy
.
的长度相同
我正在尝试根据 letsR
包和 lets.presab.points()
函数中的示例代码生成存在-不存在矩阵网格。
示例代码:
species <- c(rep("sp1", 100), rep("sp2", 100),
rep("sp3", 100), rep("sp4", 100))
x <- runif(400, min = -69, max = -51)
y <- runif(400, min = -23, max = -4)
xy <- cbind(x, y)
PAM <- lets.presab.points(xy, species, xmn = -93, xmx = -29,
ymn = -57, ymx = 15)
summary(PAM)
我的代码:
records <- read.csv("directoryremovedforprivacy.csv")
x <- records$lon
y <- records$lat
xy <- cbind(x, y)
PAM2 <- lets.presab.points(xy, records, xmn = -11.5, xmx = 3,
ymn = 49, ymx = 61)
summary(PAM2)
但是我收到以下错误:
Error in xy[pos, , drop = FALSE] : (subscript) logical subscript too long
In addition: Warning message:
In xtfrm.data.frame(x) : cannot xtfrm data frames
> summary(PAM2)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'object' in selecting a method for function 'summary': object 'PAM2' not found
根据错误消息,问题可能出在 lets.presab.points
中的 records
。它需要一个物种列表,但你正试图给它一个数据框。因此,在您的示例代码中, species
是一个字符向量,因此它也需要与您的代码具有相同的格式。所以,你可能需要做这样的事情(虽然我不确定你的 records
数据的格式是什么):
library(letsR)
PAM2 <- lets.presab.points(xy, records$species, xmn = -11.5, xmx = 3,
ymn = 49, ymx = 61)
species
需要与 xy
.