0

I have a data frame, shown as below:

   chr       POS length allele_1 allele_2     n
  <chr>     <int>  <int> <chr>    <chr>     <int>
1 chr10  10000704      2 (gt)11   (gt)11      14
2 chr10  10000704      2 (gt)9    (gt)9       51
3 chr10 100042462      4 (tttc)3  (tttc)3     20
4 chr10 100042462      4 (tttc)2  (tttc)2     11
5 chr17  79408714      3 (aat)4   (aat)4      11
6 chr17  79408714      3 (aat)7   (aat)7      60

I want to sum column n for each pair of chr and POS. My expected ouput should be:

chr         POS    length     n
  <chr>     <int>  <int>    <int>
1 chr10  10000704    2       65
2 chr10 100042462    4       31
3 chr17  79408714    3       71

I've searched for functions that could solve but didnt found any. Any idea for this case? Appreciated

0 Answers0