R: Finding an object specifed by multi objects -


i have data frame contains gene_id, transcript_id , dif. want find gene_id's has transcription_id corresponding dif-value of greater 20 , transcript_id corresponding dif-value of less -20.

example:

gene_id   transcript_id   dif         b               3         c               32         d              -41 x         y               2 x         z              -13 

i want find way a returned (as has c > 20 , d < -20).
should try write for loop or there package can me?

here dplyr solution. approach group_by transcript_id , filter rows based on multiple logical conditions. want want? maybe didn't it.

df %>% group_by(transcript_id) %>% filter(dif > 20 | dif < -20) source: local data frame [2 x 3] groups: transcript_id    gene_id transcript_id dif 1                   c  32 2                   d -41 

edit: comment of @thelatemail

thank testing code. provided solution here can one? let me if code still doesn't work well.

df %>% group_by(transcript_id) %>% filter(dif > 20 | dif < -20) %>% filter(gene_id == "a") source: local data frame [2 x 3] groups: transcript_id    gene_id transcript_id dif 1                   c  32 2                   d -41 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -