Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dissimilarities within the group in the package vegan [closed]

Tags:

r

vegan

I am working with abundance data from oceanographic campaigns and I am starting to work with the data using the vegan package.I know that with the simper function, you can calculate the intra-groups dissimilarities.

resultados_N_simper <- simper(especies_pw_hellinger, cluster)

a ‘dirty’ example of one of the analyses

But if I want to calculate the dissimilarities within the group, I have to use the PRIMER program. Is this right, or there is any way to calculate them using R?.

I have looked to see if it is possible and have found nothing. And I don't know if it's because it's not possible or because I haven't found the solution.

structure(list(grupo = c("Clust1", "Clust1", "Clust1", "Clust2", 
"Clust2", "Clust2"), C_cae = c(0, 0, 0, 0, 0, 0), G_arg = c(0, 
0, 0, 1261, 1581, 264), G_mac = c(0, 0, 0, 0, 0, 0), L_lep = c(0, 
0, 0, 0, 0, 0), M_lae = c(0, 0, 0, 0, 0, 0), M_adu = c(7, 13, 
44, 5, 1, 6), M_juv = c(129, 60, 104, 59, 38, 136), M_pou = c(4, 
0, 13, 166, 453, 194), M_mac = c(0, 0, 0, 0, 0, 0), N_aeq = c(0, 
0, 0, 0, 0, 0), P_ble = c(0, 0, 0, 0, 0, 0), T_sca = c(0, 0, 
0, 0, 0, 0), T_lus = c(11, 20, 6, 4, 15, 1), T_min = c(4, 0, 
0, 0, 0, 0)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L))
like image 479
Juan Carlos Avatar asked Nov 17 '25 06:11

Juan Carlos


1 Answers

vegan::vegdist() calculates the pairwise dissimilarity (Bray-Curtis dissimilarity by default, like simper) between each pair of samples:

vegdist(especies_pw_hellinger[-1])

#>           1         2         3         4         5
#> 2 0.3709677                                        
#> 3 0.2484472 0.3923077                              
#> 4 0.9127273 0.9143577 0.9025271                    
#> 5 0.9518502 0.9504814 0.9485588 0.1794586          
#> 6 0.6296296 0.8069164 0.6770833 0.5276718 0.6296021

If you're only interested in within-group dissimilarities:

especies_pw_hellinger |>
  split(~ grupo) |>
  lapply(`[`, -1) |>
  lapply(vegdist)

#> $Clust1
#>           1         2
#> 2 0.3709677          
#> 3 0.2484472 0.3923077
#> 
#> $Clust2
#>           4         5
#> 5 0.1794586          
#> 6 0.5276718 0.6296021
like image 97
Eonema Avatar answered Nov 18 '25 19:11

Eonema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!