Entering edit mode
6.0 years ago
paolo002
▴
160
Hi, I have a data frame with Fst values for different SNPs windows.
I would like to summarise the mean and median of the Fst values for each gene windows:
gene chr start Nsites Fst01 Fst02 Fst12
1 AC002310.7 16 30591000 2 1 8. 5
2 ZNF785 16 30591000 2 1 30 1
3 AC002310.7 16 30593000 2 2 4. 10
4 ZNF785 16 30593000 2 3 20. 2
5 AC002310.7 16 30595000 2 3 2. 20
6 ZNF785 16 30595000 2 6. 10. 3
Output:
gene n Fst01 Fst02 Fst12
1 AC002310.7 3 2. 4. 10
2 ZNF785 3 3. 20 2
I wrote something like this:
df %>% summarise_at(group_by(df, gene), vars(Fst01, Fst02,Fst12), funs(n(),mean))
but it is giving me the following error:
Error: `.vars` must be a character/numeric vector or a `vars()` object, not list
Call `rlang::last_error()` to see a backtrace
Any help, highly appreciated, cheers
solved on stackoverflow:
https://stackoverflow.com/questions/53874047/summarise-mean-median-data-frame-r