Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose_data() silently overwrites data columns that match .n_name #295

Closed
wpetry opened this issue Jan 4, 2022 · 1 comment
Closed

Comments

@wpetry
Copy link

wpetry commented Jan 4, 2022

problem

When data with a column that matches the .n_name argument are passed to compose_data(), the data are silently overwritten with a single integer. It's clear why the function behaves this way, and maybe it was silly for me not to realize this would be a problem with my data. Still, "n" (the default) is likely to be a common data column name, for example for data from censuses or when using binomial responses. User-specified dimension index prefixes also have the potential for naming conflicts.

reprex

library(tidybayes)
dat1 <- data.frame(successes = rbinom(10, n = 20, p = 0.5), n = 20)
compose_data(dat1)

proposed solution

Return an error, or at least warn the user when a column in data conflicts with .n_name. An informative message to help the user resolve the conflict would be helpful too. Something like,

`{column name}` is reserved for the length of the data and has been dropped.
Rename this column in the input data or modify the `.n_name` prefixing
function to resolve the conflict.
@mjskay
Copy link
Owner

mjskay commented Jan 5, 2022

Good idea, I've added a warning. Thanks!

@mjskay mjskay closed this as completed in 0742064 Jan 5, 2022
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

No branches or pull requests

2 participants