I have survey data for a group of species that are in a format similar to this:
## Source data Latitude Longitude Date Trap_type Hab_type Sp1 Sp2 Sp3 Sp4 Sp5
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Y N Y N N
# source lat2 long2 ??/??/?? Trap_1 Hab_1 N N N Y N
But I would like to have long format data more like:
## Source data Latitude Longitude Date Trap_type Hab_type Species Present
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Sp1 Y
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Sp2 N
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Sp3 Y
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Sp4 N
# source lat1 long1 ??/??/?? Trap_1 Hab_1 Sp5 N
# source lat2 long2 ??/??/?? Trap_1 Hab_1 Sp1 N
# source lat2 long2 ??/??/?? Trap_1 Hab_1 Sp2 N
# source lat2 long2 ??/??/?? Trap_1 Hab_1 Sp3 N
# source lat2 long2 ??/??/?? Trap_1 Hab_1 Sp4 Y
# source lat2 long2 ??/??/?? Trap_1 Hab_1 Sp5 N
The actual data covers ~ 14,000 collection points and ~25 species so I need a more automated fix than converting by hand - I feel like this should be simple but I can't work out how to do it. I've been trying to use an excel pivot table without much success and was hoping for a solution in either R or Excel in order to reformat this data if anybody is able to help! Thank you.