像这样的小玩意,
# A tibble: 54,173 x 42
# Groups: transcript_id [32,834]
transcript_id Rep1_Ws.2_NT.0h… Rep1_Ws.2_PopP2… Rep1_Ws.2_PopP2…
<chr> <int> <int> <int>
1 AT2G08655 0 0 0
2 AT4G04480 0 0 0
3 AT1G31380 0 0 0
4 AT1G03340 0 0 0
5 AT1G04440 10 6 19
6 AT5G13090 8 1 0
7 AT2G30190 0 0 0
8 AT1G31390 0 0 0
9 AT1G04487 0 1 0
10 AT3G10680 0 0 0
tibble %>% group_by(transcript_id) %>% summarize(Rep1_Ws.2_NT.0h… = sum(Rep1_Ws.2_NT.0h…))
一次只能汇总一列。如果我想汇总所有列怎么办?
答案 0 :(得分:1)
要在tidyverse中做到这一点:
tibble %>%
group_by(transcript_id) %>%
summarize_all(sum)
在基数R中,可以使用colSums
,但不包括第一个非数字列:
colSums(tibble[-1])