pearselab / MADcomm

Make A Database of ecological communities
Other
1 stars 15 forks source link

Example of what you're doing #1

Closed willpearse closed 5 years ago

willpearse commented 7 years ago
> comm <- matrix(c(0,1,1,0), 2, 2)
> comm
     [,1] [,2]
[1,]    0    1
[2,]    1    0
> rownames(comm) <- c("pond 1", "pond 2")
> colnames(comm) <- c("pondweed", "grass")
> comm
       pondweed grass
pond 1        0     1
pond 2        1     0
> long.format <- data.frame(species=c("pondweed","pondweed","grass","grass"), site=c("pond 1","pond 2","pond 1","pond 2"), count=c(0,1,1,0))
> long.format
   species   site count
1 pondweed pond 1     0
2 pondweed pond 2     1
3    grass pond 1     1
4    grass pond 2     0
willpearse commented 7 years ago

picante::sample2matrix

willpearse commented 7 years ago

sample2matrix(long.format[,c(2,3,1)])

willpearse commented 7 years ago

matrix2sample

willpearse commented 7 years ago

BUT remember that presence --> -1, and absence --> 0. It is important to keep this distinction!!!

willpearse commented 5 years ago

No need for this anymore...