3
I have a multi-column dataframe. How do I add the values of a column within an element of another variable? I want to do this to summarize the data of each species within each campaign. I tried to use the summary function of the plyr package but it didn’t work. It may be because I incorrectly put the factors in the function.
campanha especie frequencia
1 A 2
1 A 1
1 A 3
1 A 5
1 B 1
1 B 2
1 B 1
1 B 6
1 B 1
1 C 3
1 C 1
1 C 8
1 C 4
2 A 2
2 A 8
2 A 4
2 A 5
2 B 4
2 B 2
2 B 6
2 B 1
2 C 3
2 C 1
2 C 9
Thanks @Marcus Nunes! It worked. But do you think there’s a difference when I use the dplyr package or plyr? Because when I used the plyr package, it summarized all the data in one value. But when I cleaned and used the dplyr package it worked.
– Jussara
I don’t know how to use the
plyr
, then unfortunately I can not opine. What I know is thedplyr
is newer and if both packages are loaded simultaneously, errors may occur in the R session.– Marcus Nunes
@Marcusnunes From this answer, if I wanted to sum all the lines, that is, add the answers from A to B with C? 11+11+16+19....
– Letícia Marrara