How can I count the alphabat of column 2 against similar number of column one in R
I have the data in two columns C1 and C2.
C1 C2
1 a
1 a
1 x
1 z
2 a
2 y
3 x
3 x
3 x
3 z
..
I want the output in the form how many time alphabet occurs against a specific number of C1.
For example select all the number "1" from column one and then search how many time alphabet occurs against the selected number. and then go for the next umber of column 1 do the same thing and so on till last.
1 a(2)
x(1)
z(1)
2 a(1)
y(1)
3 x(3)
z(1)
..
Please suggest me how can I get the desired output.
Thanks in advance
• 1,687 views
•
link
0 answers
No answers yet.
Log in to answer this question.
What have you tried? There are multiple ways to do this sort of thing, try a few things that come to your mind and then ask for help if the performance sucks or you can't get things to work properly.
I tried it in R with the following:
I receieved the output in this form
I want to print query id only one . For example
So iterate over the rows and just don't print the first cell if it matches that from the previous row. You could do this with a "for loop" or with split() and then lapply() (this method might be faster).
I tried to count the how many time a gene is present against the query ID with the loop. But its not working. I am absolutely new in programming If I had made some mistake I hope you will forgive me. I need your suggestions to correct it.
Hello tcf.hcdg!
We believe that this post does not fit the main topic of this site.
Not a bioinformatics question, no effort put into finding a solution
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!