Hi there,
I have a tibble called mep looks like the following
# A tibble: 5,623 x 4
# Groups: id, time, interv [80]
id interv mep time
<chr> <chr> <dbl> <chr>
1 Sub01 excitation 0.377 pre
2 Sub01 excitation 0.494 pre
3 Sub01 excitation 1.55 pre
4 Sub01 excitation 0.965 pre
5 Sub01 excitation 1.04 pre
6 Sub01 excitation 0.748 pre
7 Sub01 excitation 1.14 pre
8 Sub01 excitation 0.416 pre
9 Sub01 excitation 0.0532 pre
10 Sub01 excitation 1.11 pre
# ... with 5,613 more rows
I bootstrapped this tibble using
boots_mep <- bootstraps(mep, times = 2000, apparent = TRUE)
and got
# Bootstrap sampling with apparent sample
# A tibble: 2,001 x 2
splits id
<list> <chr>
1 <split [5623/2021]> Bootstrap0001
2 <split [5623/2060]> Bootstrap0002
3 <split [5623/2042]> Bootstrap0003
4 <split [5623/2045]> Bootstrap0004
5 <split [5623/2060]> Bootstrap0005
6 <split [5623/2075]> Bootstrap0006
7 <split [5623/2027]> Bootstrap0007
8 <split [5623/2065]> Bootstrap0008
9 <split [5623/2055]> Bootstrap0009
10 <split [5623/2107]> Bootstrap0010
# ... with 1,991 more rows
I would like to do a simple averaging on mep within each split, such averaging should be group by id, time and interv, I did as follows but it could not work with errors
boots_mep %>%
mutate(mep_avg = map2(splits, analysis(splits)
~{group_by(id, time, interv) %>%
summarize(avg_mep = mean(mep, na.rm=TRUE))}),
tidied = map(mep_avg, tidy)) %>%
unnest(cols = tidied) %>%
Could you please help? I am not sure if I should have used map instead of map2, and the syntax seems also wrong. Thanks a lot.