vegan - Error when using R betadisper function -
the 'betadisper' funtion in vegan [r] calculates multivariate dispersion of group of sites based on distances
i have distance matrix multiple groups of sites:
dis <- vegdist(correct_tree_data)
i created 'groups' using 'factor' function (23 levels 23 groups of sites), , each group has different no. of sites
groups <- factor(c(rep(1,144), rep(2,49), rep(3,121), rep(4,81), rep(5,81), rep(6,81), rep(7,36), rep(8,289), rep(9,324), rep(10,225), rep(11,256), rep(12,225), rep(13,289), rep(14,289), rep(15,144), rep(16,225), rep(17,225), rep(18,225), rep(19,225), rep(20,225), rep(21,225), rep(22,225), rep(23,225)), labels = c("s1_05","s2_05","s3_05","s4_05","s5_05","s6_05","s7_05","s1_10","s2_10","s3_10","s4_10","s5_10","s6_10","s7_10","s8_10","s1_15","s2_15","s3_15","s4_15","s5_15","s6_15","s7_15","s8_15"))
when using 'betadisper' function, however, following error message:
mod <- betadisper(dis, groups)
error in pts[groups == i, , drop = false] : (subscript) logical subscript long
the levels match amount of groups in distance matrix no. of replicates in each group
what else may contributing error?
as long dimensions/lengths match function should work fine:
require(vegan) data(varespec) dis <- vegdist(varespec) group <- factor(rep("grazed", nrow(varespec))) mod <- betadisper(dis, group) mod
homogeneity of multivariate dispersions
call: betadisper(d = dis, group = group)
no. of positive eigenvalues: 15 no. of negative eigenvalues: 8
average distance median: grazed 0.4255
eigenvalues pcoa axes: pcoa1 pcoa2 pcoa3 pcoa4 pcoa5 pcoa6 pcoa7 pcoa8 1.7552 1.1334 0.4429 0.3698 0.2454 0.1961 0.1751 0.1284
however if factor length longer should you'll error:
group <- c(group, "extra data") betadisper(dis, group)
error in pts[groups == i, , drop = false] : (subscript) logical subscript long
i know don't think problem you're having, if provide reproducible example can investigate specific case further.
Comments
Post a Comment