Add col_binomial_vec wrapper function to handle vectors with missing data#34
Add col_binomial_vec wrapper function to handle vectors with missing data#34
Conversation
|
@copilot col_binomial is also useful when we want to quickly calculate proportions. The data we typically use however, has missing data making proportion calculation a bit unwieldy. The user would typically need to:
Can you write a wrapper function that takes a single vector, and returns the proportion, as well as other statistics provided by The wrapper function might also be used for other |
Co-authored-by: g-hyo <14864611+g-hyo@users.noreply.github.com>
Co-authored-by: g-hyo <14864611+g-hyo@users.noreply.github.com>
Co-authored-by: g-hyo <14864611+g-hyo@users.noreply.github.com>
I've implemented the wrapper function The function:
Example usage: # Basic 0-1 vector with missing data
x <- c(0, 1, 1, 0, NA, 1, 0, 1)
col_binomial_vec(x)
# Custom range (1-2)
y <- c(1, 2, 2, 1, NA, 2, 1, 2)
col_binomial_vec(y, success_value = 2, range = c(1, 2))Implemented in commit 608e639. 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
Adds a new wrapper function
col_binomial_vec()that simplifies proportion calculations for vectors with missing data.Changes Made
New function
col_binomial_vec(): A wrapper forcol_binomial()that automatically handles:Comprehensive test coverage: Added 8 test cases covering various scenarios including basic usage, custom ranges, multiple success values, NA handling, and error cases
Documentation: Added roxygen documentation with usage examples
Motivation
Previously, users had to manually filter data and calculate statistics before calling
col_binomial():Now, users can calculate proportions with a single line:
Usage Examples
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.