# Example with a data frame
df <- data.frame(
Species1 = c(10, NA, 15),
Species2 = c(5, 10, NA),
Species3 = c(8, 12, 10),
row.names = c("A", "B", "C")
)
num_species(df)
# Example with a matrix
mat <- matrix(c(10, NA, 15, 5, 10, NA, 8, 12, 10), nrow = 3, byrow = TRUE)
colnames(mat) <- c("Species1", "Species2", "Species3")
row.names(mat) <- c("A", "B", "C")
num_species(mat)
Run the code above in your browser using DataLab