dplyr::mutate to add multiple values

前端 未结 6 1588
旧时难觅i
旧时难觅i 2020-11-30 04:15

There are a couple of issues about this on the dplyr Github repo already, and at least one related SO question, but none of them quite covers my question -- I think.

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 04:26

    Here's a quick solution using data.table package instead

    First, a little change to the function

    get_binCI <- function(x,n) as.list(setNames(binom.test(x,n)$conf.int, c("lwr", "upr")))
    

    Then, simply

    library(data.table)
    setDT(dd)[, get_binCI(x, n), by = .(x, n)]
    #    x  n        lwr       upr
    # 1: 3 10 0.06673951 0.6524529
    # 2: 4 11 0.10926344 0.6920953
    

提交回复
热议问题