Thank you. Let me try it out
• 0 views
•
link
Hi All,
I am trying to filter out genes from my gene-fusion excel file. I want to remove any gene which is getting repeated more than 10 times in the column. I am doing this in R.
Any suggestions??
Thanks in advance.
Assuming you have your data stored in a data.frame named df, you could use dplyr::group_by and dplyr::n to count the number of instances of each value in the target column (e.g., a), and add these as a new column (b). Then you can filter the data.frame using this new column.
library(magrittr)
library(dplyr)
df %>%
group_by(a) %>%
mutate(b = n()) %>%
ungroup() %>%
filter(b <= 10) %>%
select(-b)
`
Thank you. Let me try it out
Log in to answer this question.
Using plain R , this should work :
Thank you Hamid. Let me try it out.