so I need to calculate alpha diversity (simpson) for a database I got for the fish found in six different sites (12 entries, 6 columns) . When I use the diversity() function in the vegan package I get an error as it calculates each of the 12 entries as simpson for the species, instead of using the six sites. I even compared with the dune database in the vegan package and I can't just figure out what I'm doing wrong.
This is my code so far:
if (!require(ggplot2)) install.packages('ggplot2')
library(ggplot2)
if (!require(ggpubr)) install.packages('ggpubr')
library(ggpubr)
if (!require(tidyverse)) install.packages('tidyverse')
library(tidyverse)
if (!require(vegan)) install.packages('vegan')
library(vegan)
if (!require(labdsv)) install.packages('labdsv')
library(labdsv)
Abundancia2017<- c(0,36,0,9,0,0,46,0,0,0,25,0)
Abundancia2018<- c(0,46,0,13,5,0,69,2,0,0,123,9)
Abundancia2019<- c(4,20,0,38,2,1,97,0,0,0,12,0)
datafish <- data.frame(Abundancia2017,Abundancia2018, Abundancia2019) datafish
I run the diversity function and I get the following result:
> diversity(datafish,index = "simpson")
[1] 0.0000000 0.6336025 1.0000000 0.5294444 0.4081633 0.0000000 0.6376379 0.0000000 1.0000000 1.0000000
[11] 0.3789844 0.0000000
Please help me, I've already tried swapping columns and rows in the.csv document and nothing seems to work