The 'betadisper' funtion in vegan [R] calculates the multivariate dispersion of a group of sites based on their distances
I have a distance matrix with multiple groups of sites:
dis <- vegdist(correct_tree_data)
I created my 'groups' using the 'factor' function (23 levels for 23 groups of sites), and each group has a 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 the 'betadisper' function, however, I get the following error message:
mod <- betadisper(dis, groups)
Error in pts[groups == i, , drop = FALSE] : (subscript) logical subscript too long
The levels do match the amount of groups in the distance matrix as well as the no. of replicates in each group
What else may be contributing to this error?