Difference between revisions of "Diversity index"

From Testiwiki
Jump to: navigation, search
(Answer: names added to objects)
(Answer: names added to objects)
Line 29: Line 29:
 
}
 
}
 
}
 
}
names(qD) <- q
+
 
 +
q[q == 999] <- "∞"
 +
names(out) <- q
 
return(out)
 
return(out)
 
}
 
}
Line 45: Line 47:
 
out[q == 999] <- minqDj[q == 999]
 
out[q == 999] <- minqDj[q == 999]
 
q[q == 999] <- "∞"
 
q[q == 999] <- "∞"
names(qDa) <- q
+
names(out) <- q
return(out)
+
return(out)
 
}
 
}
  
Line 81: Line 83:
 
alpha <- qDa(qDj, wj$wj, q)
 
alpha <- qDa(qDj, wj$wj, q)
 
dim(qDj) <- c(length(q), length(qDj)/length(q))
 
dim(qDj) <- c(length(q), length(qDj)/length(q))
dimnames(qDj) <- list(q, levels(as.factor(transect)))
+
q[q == 999] <- "∞"
 +
dimnames(qDj) <- list(q, levels(as.factor(pij$Transect)))
  
 
return(list(gamma = gamma, alpha = alpha, tr.gammas = t(qDj)))
 
return(list(gamma = gamma, alpha = alpha, tr.gammas = t(qDj)))
Line 164: Line 167:
 
transect <- data$Transect
 
transect <- data$Transect
  
cat("Different diversities with the following q values \n")
 
q.wiki
 
 
diversity(amount, species, transect, q.wiki)
 
diversity(amount, species, transect, q.wiki)
 
print(xtable(diversity(amount, species, transect, q.wiki)[[3]]), type = 'html')
 
print(xtable(diversity(amount, species, transect, q.wiki)[[3]]), type = 'html')

Revision as of 04:53, 11 January 2012



Question

How to calculate diversity indices?

Answer

Upload your data to Opasnet Base. Use the function diversity to calculate the most common indices.

Actual function diversity

+ Show code

The function diversity produces a list where the first, second, and third element are the gamma, the alpha, and transect-specific gamma diversities, respectively.

Function diversity.table produces a data.frame of several diversity indices.

Examples

Example 1 to use function

Give your data in R format or leave empty for example data:

Is your data individual data or group abundancies?:

+ Show code

Example 2

Select your data:

Which q values you want to calculate.:
0
0.5
1
2
3
6

+ Show code

The data should be given in R format as a list of values in parenthesis, beginning with c:

c(3,5,3,5,2,1,3,3,4,2) or equivalently c(0.1,0.2,0.4,0.1,0.2)

where the values are either

  • identifiers of the species 1,2,3... in which the individuals belong (one entry per individual), or
  • abundancies of species, i.e. proportions of individuals belonging to each species among the whole population (one entry per species).

Rationale

Diversity indices are thoroughly described in Wikipedia.

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>