0

My data looks like this

PDB.ID Chain.ID Space.Group     Uniprot.Recommended.Name
101M        A         P 6   Myoglobin
102L        A    P 32 2 1   Endolysin
102M        A         P 6   Myoglobin
103L        A    P 32 2 1   Endolysin
103M        A         P 6   Myoglobin
104L        A       H 3 2   Endolysin

After reading the data and loading the required package

df <- read.delim("~/Downloads/dummy2.tsv")
library(dplyr)

I can count the number of entries for a specific variable with code like this

df %>% count(Uniprot.Recommended.Name)

Or alternatively

df %>% +
group_by(Uniprot.Recommended.Name) %>% +
  summarise( +
    count = n() +
) 

I get two columns, a count for every case of Uniprot.Recommended.Name

My question: Is it possible to get a table with two counts. Counting the number of entries for every Space.Group per Uniprot.Recommended.Name.

Expected table should be like something like this

Myoglobin    P 6         123
Myoglobin    P 32 2 1    124
Endolysin    P 32 2 1    125
Endolysin    H 3 2       126

Thanks

murpholinox
  • 639
  • 1
  • 4
  • 14
  • I am sorry for the images, I do not know how to input tables. – murpholinox Feb 06 '20 at 23:30
  • 1. Please don't post links to data, or screenshots of results, instead provide sample data in your post. See [mcve], also see [instructions](https://stackoverflow.com/editing-help) for formatting posts if you're not sure how to input data. 2. [`group_by()`](https://dplyr.tidyverse.org/reference/group_by.html) accepts multiple arguments. that should accomplish your goal. – andrew_reece Feb 06 '20 at 23:30
  • 2
    And also `count` accepts multiple arguments. So `df %>% count(Uniprot.Recommended.Name, Space.Group)` should work. – Ronak Shah Feb 06 '20 at 23:48
  • @andrew_reece, sorry I will edit my post. I did look into the link you provided but I did not see anything with respect to tables. I'll try to do my best. – murpholinox Feb 06 '20 at 23:57
  • @RonakShah Would you mind creating the answer. It works. – murpholinox Feb 06 '20 at 23:58
  • 2
    Thanks, glad it worked. Actually, this has been asked and answered before. I have marked it as a duplicate of that post. I hope that is fine. – Ronak Shah Feb 07 '20 at 00:03
  • @RonakShah Great. – murpholinox Feb 07 '20 at 00:05

0 Answers0