Dplyr question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dplyr question

Nico Gutierrez
Hi All,

Trying to get familiar with dplyr so I have a basic question:

How to summarise sum(Values) per species, maintaining Code column (each species has a Code):

          Species Values     Code
1        Acanthocybium solandri        33         LC
2        Makaira nigricans         20         VU
3        Makaira nigricans                 20         VU
4.       Makaira nigricans                 20       VU
5  Sarda sarda                 2       LC
4        Lethrinus lentjan                   12         LC
5        Raja pita         8         DD
6        Raja pita   2 DD

I need:

         Species Values     Code
1        Acanthocybium solandri        33         LC
2        Makaira nigricans         60         VU
3  Sarda sarda                 2       LC
4        Lethrinus lentjan                   12         LC
5        Raja pita         10         DD


Thanks :)
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Dplyr question

Dr Eberhard W Lisse
This is well described in the manual.

Sounds like homework...

el

On 15/10/2020 12:39, Nico Gutierrez wrote:

> Hi All,
>
> Trying to get familiar with dplyr so I have a basic question:
>
> How to summarise sum(Values) per species, maintaining Code column (each species has a Code):
>
>           Species Values     Code
> 1        Acanthocybium solandri        33         LC
> 2        Makaira nigricans         20         VU
> 3        Makaira nigricans                 20         VU
> 4.       Makaira nigricans                 20       VU
> 5  Sarda sarda                 2       LC
> 4        Lethrinus lentjan                   12         LC
> 5        Raja pita         8         DD
> 6        Raja pita   2 DD
>
> I need:
>
>          Species Values     Code
> 1        Acanthocybium solandri        33         LC
> 2        Makaira nigricans         60         VU
> 3  Sarda sarda                 2       LC
> 4        Lethrinus lentjan                   12         LC
> 5        Raja pita         10         DD
>
>
> Thanks :)
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

--
Dr. Eberhard W. Lisse   \         /       Obstetrician & Gynaecologist
[hidden email]             / *      |  Telephone: +264 81 124 6733 (cell)
PO Box 8421 Bachbrecht  \      /  If this email is signed with GPG/PGP
10007, Namibia           ;____/ Sect 20 of Act No. 4 of 2019 may apply

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.