[R] For help in R coding

Bansal, Vikas vikas.bansal at kcl.ac.uk
Fri Jul 1 18:47:47 CEST 2011

Dear all,

I am doing a project on variant calling using R.I am working on pileup file.There are 10 columns in my data frame and I want to count the number of A,C,G and T in each row for column 9.example of column 9 is given below-


This is a bit confusing for me as these characters are in one column and how can we scan them for each row to print number of A,C,G and T for each row.
Most of the rows have      .         and      ,    and other symbols but we will ignore them.I just want to run a loop with a counter which will count the number of A,C,G and T for each row and will give output something like this-

A   C   G  T
1   0   1  0
0   0   0  2
0   2   0  0
1   0   0  0
0   0   0  3

This output is for first 5 rows from the example given above.

I am new to R can you please help me.I will be very thankful to you.

Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London

More information about the R-help mailing list