Skip to content

Species Co0ccurance

1 message · Etienne Laliberté

#
Hi Lanna,

What you're describing can be easily done via the reshape package:

# test data
data <- data.frame(year = factor(2001:2010), location = gl(2, 5), type =
gl(10, 1), species = gl(5, 2), freq = rbinom(10, 1, .5) )

library(reshape)

data <- melt(data)
data2 <- cast(data, year + location + type ~ species, fill = 0)

Cheers