I'm trying to solve the following problem in R: I have a dataframe with two variables (number of successes, and number of total trials).
# A tibble: 4 x 2
Success N
<dbl> <dbl>
1 28. 40.
2 12. 40.
3 22. 40.
4 8. 40.
I would like to perform a prop.test or binom.test on each row and add the resulting list to the dataframe (or certain elements of it, like the p-value and CIs).
Ideally, I would like to add a third column with the p-values and the CI-range. My attempts so far were painly unsuccessful. Here is a minimal coding example:
Success <- c( 38, 12, 27, 9)
N <- c( 50, 50, 50, 50)
df <- as.tibble( cbind(Success, N))
df %>%
map( ~ prop.test, x = .$Success, n = .$N)
Doesn't give the desired result. Any help would be much appreciated.
Cheers,
Luise
cols
is now required.Please usecols = c(result)
unnest(cols=c("result")) – Cattle