• 0 views
•
link
conditional count of occurrence in R
I know how to count repeated fields in a column simply by using table(file$column)
> exon intron CDS mRNA
234 235 7564 27465
now I want to know how I can count these fields in a column based on the values of another column, e.g.
col1 col2 col3 col4 col5 col6 col7 col8 col9
scf001 74212 85524 mRNA - ERV 1659 1689 30
scf002 35002 48200 CDS + ERV2 16 81 62
scf0101 82177 82314 exon - DUF 465 615 137
scf00273 74212 85524 intron + AZUR 612 766 135
I want to count the number of occurrence for col4 for values of equal or greater than 80 in col9, how can I do that?
• 1,800 views
•
link
1 answer
In the tidyverse:
data %>% filter(col9 >= 80) %>% select(col4) %>% table
• 0 views
•
link
Thanks, can you explain what %>% does in this package?
• 0 views
•
link
%>% is the dplyr pipe: https://style.tidyverse.org/pipes.html. It passes the output of one command to the input of the next.
• 0 views
•
link
Log in to answer this question.