I am trying to adjust my data into a format that can be used in the R package BAT. My data is currently formatted as:
Cover, ScientificName, PinTag
3, Elymus.virginicus, AA16
4, EUONYMUS.FORTUNEI, AA16
5, GLECHOMA.HEDERACEA, AA16
3, EUONYMUS.FORTUNEI, AA17
2, GLECHOMA.HEDERACEA, AA17
2, Acer.negundo, AA19
4, Elymus.virginicus, AA19
I am trying to reformat my data into the following:
PinTag, Acer.negundo, Elymus.virginicus, EUONYMUS.FORTUNEI, GLECHOMA.HEDERACEA
AA16, 0, 3, 4, 5
AA17, 0, 0, 3, 2
AA19, 2, 4, 0, 0
I tried the following based on an earlier post:
library(reshape2)
MyData <- dcast(QuadratCoverBAT, PinTag~ScientificName, value.var="Cover")
Which gave the error message "Aggregation function missing: defaulting to length" and provided an output on my full dataset (1821 obs) of:
PinTag, Acer.negundo, Elymus.virginicus, EUONYMUS.FORTUNEI, GLECHOMA.HEDERACEA
AA16, 0, 1, 1, 1
AA17, 0, 0, 1, 1
AA19, 1, 1, 0, 0
There should be no duplicated data in the dataset, but R tells me I have 208 duplicates when I run
anyDuplicated(QuadratCoverBAT)
If the results were 1 or 2, I could believe I had made a mistake and missed a duplicate in the data, but there is no way I've missed over 200...
Any help would be greatly appreciated!
EDIT: Here is a link to the full data file - [deleted link]