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

Add documentation clarifying appropriate use of weights in slice_sample() #7052

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

apeterson91
Copy link
Contributor

@apeterson91 apeterson91 commented Jul 14, 2024

Users may be led astray by the current language describing weighted sampling via slice_sample(). As discussed in https://stats.stackexchange.com/q/639211/ and elaborated on in issue #6848, there's more nuance to how weights might be used for sampling. The current base R algorithm which slice_sample() relies on does not use the sampling weights in a way that conform to how a user might suspect the weights ought to work, as in Horvitz Thompson estimation for example.

I've added appropriate details here in the documentation including the above link for further details.

@etiennebacher
Copy link

Hi, I'm not a member of the tidyverse team, but I just want to point out that you need to redocument the package to include this change in the .Rd file. You can use devtools::document(), or comment "/document" (without the quotes) in this PR to trigger a github action workflow (I'm not sure the latter will work).

@apeterson91
Copy link
Contributor Author

apeterson91 commented Jul 17, 2024

Thanks @etiennebacher! Been a bit since I've built an R package locally – appreciate the reminder.

Copy link

@skolenik skolenik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of the problem is insufficient. I can poke at a more accurate answer with better references to both methodology and the existing R libraries.

(I would also point out that it is a somewhat better practice to name your branches informatively rather than main -- I would have called this slice_sample_7052 to indicate the function affected and the issue number.)

@apeterson91
Copy link
Contributor Author

I don't completely follow the first part of your comment, but your edits LGTM.

I would also point out that it is a somewhat better practice to name your branches informatively

Acknowledged. I'll follow this convention in the future.

@DavisVaughan DavisVaughan merged commit cfb25a0 into tidyverse:main Aug 27, 2024
11 checks passed
@DavisVaughan
Copy link
Member

Thanks @apeterson91!

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.

4 participants