Simulate community-by-species matrix of "functioning" (e.g., biomass) where the total community richness has a predefined correlation with total community biomass (i.e., the row sums).
# Generate community data
ncomms <- 100
nspecies <- 20
rho <- 0.5
mat <- simulateComm(rho, nspecies, ncomms, propzero = 0.8)
# Get correlation
cor(rowSums(mat), rowSums(mat > 0))