library(tidyverse)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
## -- Attaching packages -------------------------------------- tidyverse 1.2.1 --
## <U+221A> ggplot2 3.1.1 <U+221A> purrr 0.3.2
## <U+221A> tibble 2.1.1 <U+221A> dplyr 0.8.1
## <U+221A> tidyr 0.8.3 <U+221A> stringr 1.4.0
## <U+221A> readr 1.3.1 <U+221A> forcats 0.4.0
## -- Conflicts ----------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
start_k=tibble(e1=c(1, 2, 3), p1=c(2, 3, 5),
e2=c(1, 2, 3), p2=c(3, 1, 2))
tabel<- sapply(1:2, function(nr){
enimi <- paste("e", nr, sep="")
pnimi <- paste("p", nr, sep="")
tt <- t.test(as.numeric(start_k[[enimi]]), as.numeric(start_k[[pnimi]]), paired = TRUE, alternative = "two.sided")
c(nr, tt$p.value, tt$conf.int[1], tt$conf.int[2])
})
tabel %>% t() %>% as_tibble() %>% rename(jnr=V1, p=V2, alates=V3, kuni=V4)
## Warning: `as_tibble.matrix()` requires a matrix with column names or a `.name_repair` argument. Using compatibility `.name_repair`.
## This warning is displayed once per session.
## # A tibble: 2 x 4
## jnr p alates kuni
## <dbl> <dbl> <dbl> <dbl>
## 1 1 0.0572 -2.77 0.101
## 2 2 1 -4.30 4.30