I have a data frame that looks more or less like this
df <- tribble(
~Species, ~Symbiont, ~Location,
"a", "s01", "P01",
"b", "s02", "P01",
"c", "s01", "P02",
"a", "s03", "P03",
"d", "s02", "P02",
"c", "s04", "P04",
"a", "s03", "P01",
"c", "s02", "P02",
"c", "s03", "P02"
)
What I'd like to to achieve is to have a single row for each Species in each Location, and a presence-absence 0-1 info about the Symbiont.
For example, with the given data,
Species s01 s02 s03 s04 Location
a 1 0 1 0 P01
a 0 0 1 0 P03
b 0 1 0 0 P02
c 1 1 1 0 P02
c 0 0 0 1 P04
d 0 1 0 0 P02
I'd like to use tidyverse as I'm more comfortable with it but whatever works
I'll spare you the goofy attempt I've tried...
Thank you!