You can try to work on formating the result of your t-test to be able to use tidy tools.
Here is one way - and surely not the only one and more efficient one.
library(tidyverse)
tibble(a = list(c(1, 2), c(3, 4))) %>%
mutate(low_high = map(a, ~t.test(., conf.level = 0.95)$conf.int %>%
# name the t-test resulting numeric vector
set_names(c("low", "high")) %>%
# transform the vector in tibble
enframe)) %>%
# unnest only this column (keep the a list column)
unnest(low_high, .drop = FALSE) %>%
# spread result using tidy to have two column
spread(name, value)
#> # A tibble: 2 x 3
#> a high low
#> <list> <dbl> <dbl>
#> 1 <dbl [2]> 7.85 -4.85
#> 2 <dbl [2]> 9.85 -2.85
Created on 2018-09-10 by the reprex package (v0.2.0).
Another way: the broom
you can use broom to tidy the t.test result. You’ll get tibble that you can filer to select the result you.
library(tidyverse)
library(broom)
tibble(a = list(c(1, 2), c(3, 4))) %>%
mutate(ttest = map(a, t.test, conf.level = 0.95) %>% map(tidy) %>% map(~ select(., conf.low, conf.high))) %>%
unnest(ttest, .drop = FALSE)
#> # A tibble: 2 x 3
#> a conf.low conf.high
#> <list> <dbl> <dbl>
#> 1 <dbl [2]> -4.85 7.85
#> 2 <dbl [2]> -2.85 9.85
I let you see want broom::tidy returns.