Skip to content

Add col_binomial_unpack() for extracting vector or dataframe from col_binomial#35

Draft
Copilot wants to merge 3 commits intocopilot/add-wrapper-function-col-binomialfrom
copilot/add-col-binomial-output-function
Draft

Add col_binomial_unpack() for extracting vector or dataframe from col_binomial#35
Copilot wants to merge 3 commits intocopilot/add-wrapper-function-col-binomialfrom
copilot/add-col-binomial-output-function

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 7, 2026

Adds a function to convert col_binomial objects into either a numeric vector (default) or a dataframe with configurable fields including confidence intervals.

Changes

  • New function col_binomial_unpack(): Extracts data from col_binomial objects

    • Returns numeric vector of point estimates by default
    • Optional dataframe output with configurable fields
    • Default dataframe includes p, ci_lower, ci_upper
    • All fields available: n, N, population, ci_error, p, ci_lower, ci_upper, note
  • Tests: 8 test cases covering vector output, dataframe output, custom fields, and error handling

  • Documentation: Generated roxygen2 docs for col_binomial_unpack() and col_binomial_vec() (previously missing)

Usage

b_trials <- stats::rbinom(1000, 1, 0.5)
result <- col_binomial(b_trials)

# Vector output (default)
col_binomial_unpack(result)
#> 0.523

# Dataframe with confidence intervals
col_binomial_unpack(result, output = "dataframe")
#> # A tibble: 1 × 3
#>       p ci_lower ci_upper
#>   <dbl>    <dbl>    <dbl>
#> 1 0.523    0.493    0.554

# Custom fields
col_binomial_unpack(result, output = "dataframe", fields = c("p", "n", "N"))
#> # A tibble: 1 × 3
#>       p     n     N
#>   <dbl> <int> <int>
#> 1 0.523   523  1000

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.r-project.org
    • Triggering command: /usr/lib/R/bin/exec/R /usr/lib/R/bin/exec/R --no-echo --no-restore -e install.packages(&#39;roxygen2&#39;,~&#43;~repos=&#39;REDACTED&#39;,~&#43;~dependencies=TRUE) nap --from-apt 2&gt;/dev/null || true (dns block)
  • cran.rstudio.com
    • Triggering command: /usr/lib/R/bin/exec/R /usr/lib/R/bin/exec/R --no-echo --no-restore -e options(repos~&#43;~=~&#43;~c(CRAN~&#43;~=~&#43;~&#39;REDACTED&#39;));~&#43;~install.packages(&#39;roxygen2&#39;,~&#43;~dependencies=TRUE) (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Pull request: https://github.com/socialresearchcentre/projectable/pull/34/files

Add a function that takes the output of col_binomial and converts it into either a vector, or a dataframe depending on what the user requests (i.e. they could request confidence intervals as well using prj_shadow)

The default output should be a vector


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 7, 2026 08:17
Co-authored-by: g-hyo <14864611+g-hyo@users.noreply.github.com>
Co-authored-by: g-hyo <14864611+g-hyo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add function to convert col_binomial output Add col_binomial_unpack() for extracting vector or dataframe from col_binomial Jan 7, 2026
Copilot AI requested a review from g-hyo January 7, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants