我使用 R 包 vegan 来检查数据集中的嵌套性:
bc_rp <- read.csv("BC_RPc.csv", na.strings = c("","NA"), header=TRUE, check.names = FALSE)
bc_rp
bc <- data.frame(
cell_layer = c("H", "B", "A", "G", "O"),
Np = c(0, 1, 1, 0, 0),
Pn = c(1, 1, 0, 0, 1),
Npn = c(0, 1, 0, 0, 0),
Npnp = c(0, 1, 0, 0, 0),
Pnp = c(1, 0, 0, 0, 0),
Pnpn = c(0, 1, 0, 0, 0)
)
# Renamed the columns to be easier to manipulate and have no special characters
# colnames(hc) <-c('species', 'a','b','c','d','e','f','g')
# Transpose the rows and columns in data.
bc_t <-t(bc)
out_bc_t <- nestedtemp(bc_t)
out_bc_t
#nestedness temperature: 10.24168
#with matrix fill 0.4
plot(out_bc_t, kind="incid")
此代码按预期工作,生成嵌套温度和绘图。
但是,我希望可以将绘图的颜色更改为红色以外的颜色,并为每种细胞类型和类别(np、pn 等)添加标签,我该怎么做?
一个好的起点是函数的文档(尝试
?nestedtemp
)。 plot
的 nestedtemp
函数似乎有参数 col
可用于设置颜色,而 names
默认为 names = FALSE
,但设置 TRUE
会添加名称(根据文档至少——我没有尝试)。如果这些对您没有帮助,请提出更详细的问题。