对于X1
中的每个唯一字符串,我想获得value
为正数和负数的实例数。
数据:
> head(tab_split_merge.m)
IsomiR logCPM LR PValue FDR X1 X2 variable value
1 hsa-miR-135b-5p_TATGGCTTTTCATTCCTATGTGAA 3.7839592 96.44248 9.187474e-23 2.002777e-18 hsa-miR-135b-5p TATGGCTTTTCATTCCTATGTGAA logFC 4.741782
2 hsa-miR-135b-5p_TATGGCTTTTCATTCCTATGTGA 5.6750976 93.55073 3.959207e-22 4.315338e-18 hsa-miR-135b-5p TATGGCTTTTCATTCCTATGTGA logFC 4.105579
3 hsa-miR-135b-5p_TATGGCTTTTCATTCCTATGTG 4.7075541 91.62360 1.048355e-21 7.617695e-18 hsa-miR-135b-5p TATGGCTTTTCATTCCTATGTG logFC 4.120676
4 hsa-miR-21-5p_GTAGCTTATCAGACTGATGTTGACC 0.5600979 79.52288 4.766726e-19 2.597746e-15 hsa-miR-21-5p GTAGCTTATCAGACTGATGTTGACC logFC 3.811973
5 hsa-miR-135b-3p_ATGTAGGGCTAAAAGCCATGGG 0.9542581 75.22223 4.206038e-18 1.833749e-14 hsa-miR-135b-3p ATGTAGGGCTAAAAGCCATGGG logFC 4.268764
6 hsa-miR-497-3p_CAAACCACACTGTGGTGTTGGA 1.5307936 60.67202 6.742159e-15 2.449539e-11 hsa-miR-497-3p CAAACCACACTGTGGTGTTGGA logFC -3.126917
输出:
mir up down
hsa-miR-21-5p 1 0
hsa-miR-135b-5p 4 0
hsa-miR-497-3p 0 1
答案 0 :(得分:3)
您可以在对数据集进行子集化后使用table
table(transform(df1[c('X1', 'value')], value=value>0))