Hello!
I have a dataframe sum
and I am simply trying to take the sum of sum$TAXON_COUNT_indiv_m2
after grouping sum$TAXON
. It shouldn't be that hard but I keep getting this error:
Error: Problem with `summarise()` input `..1`.
i `..1 = across(TAXON_COUNT_indiv_m2, sum)`.
x Can't convert a character vector to function
i The error occurred in group 1: TAXON = "Ablabesmyia".
Here is my code:
sum1 <- sum %>%
group_by(TAXON) %>%
summarise(across(TAXON_COUNT_indiv_m2, sum))
Can anyone help me figure out what I'm doing wrong? I also tried using summarise_at()
with the below code:
sum1 <- sum %>%
group_by(TAXON) %>%
summarise_at(vars(TAXON_COUNT_indiv_m2), list(names=sum))
But then I got this error: Error: expecting a one sided formula, a function, or a function name.
Below is a subset of my dataset. Thanks so much for any help!
sum <- structure(list(TAXON = c("Chironomidae pupae", "Chironomidae pupae",
"Chironomidae pupae", "Chironomidae pupae", "Chironomidae pupae",
"Chironomidae pupae", "Chironomidae pupae", "Chironomidae pupae",
"Chironomidae pupae", "Chironomidae pupae", "Chironomidae pupae",
"Chironomidae pupae", "Chironomidae pupae", "Trichoptera pupae",
"Trichoptera pupae", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche", "Cheumatopsyche",
"Cheumatopsyche", "Cheumatopsyche", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus", "Chironomus", "Chironomus",
"Chironomus", "Chironomus", "Chironomus"), TAXON_COUNT_indiv_m2 = c(6,
128, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 20, 13, 13, 7, 33,
39, 13, 13, 13, 1655, 420, 7, 71, 173, 2006, 122, 13, 6, 32,
6, 6, 6, 6, 256, 6, 19, 19, 244, 90, 71, 974, 6, 77, 391, 32,
6, 6, 38, 6, 13, 6, 6, 103, 397, 6, 39, 20, 20, 20, 7, 66, 13,
7, 7, 7, 7, 7, 7, 26, 13, 6, 13, 6, 115, 19, 135, 26, 19, 32,
51, 64, 83, 103, 147, 64, 51, 385, 160, 179, 481, 13, 83, 13,
6, 333)), row.names = c(NA, 100L), class = "data.frame")