[R] counting occurrence of text in a dataframe

Iain Gallagher iaingallagher at btopenworld.com
Sat May 23 14:44:19 CEST 2009


Hello list.

I am hoping for some help with a relatively simple problem. I have a data frame arranged as below. I want to be able to count the occurrence of each gene (eg let-7e) by Experiment. In other words how many times does a given gene crop up in the dataframe. I tried table but couldn't work out how to get the output I want. I have also considered rearranging this data into a list (by gene) and then counting the length of each gene element. However I thought that there might be a more elegant solution.  

Tanaka     Mitchell   Wang       Hunter     Chen       Chim       
miR-191*   let-7e     let-7b     miR-126    let-7a     let-7g     
miR-198    let-7f     let-7c     miR-146a   let-7b     let-7i     
miR-22     let-7g     miR-1224   miR-16     let-7d     miR-130b   
miR-223    let-7i     miR-124    miR-191    let-7f     miR-133a   
miR-296    let7fG15A  miR-125a-3pmiR-222    let-7g     miR-140    
miR-30d    miR-101    miR-125b-5pmiR-223    let-7i     miR-142-5p 
miR-370    miR-103    miR-133a   miR-24     miR-101    miR-146    
miR-486    miR-125a-5pmiR-133b   miR-26a    miR-103    miR-148a   
miR-498    miR-126    miR-135a*  miR-32     miR-106a   miR-152    

Thanks for any advice.

Cheers

Iain




More information about the R-help mailing list