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 additional solution of table() to allow for naming col/row #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sou412
Copy link
Collaborator

@sou412 sou412 commented Sep 7, 2020

Add colnames and rownames to table() solution to address #13 .

@sou412 sou412 linked an issue Sep 7, 2020 that may be closed by this pull request
@mattblackwell
Copy link
Owner

mattblackwell commented Sep 7, 2020

Yes, this is one approach, but I worry that we would have to check all possible names. What about using something like the following:

tt <- table(resume$sex, resume$call)
jj <- table(sex = resume$sex, call = resume$call)
all.equal(tt, jj, check.attributes = FALSE)

We would still have to check both ordering. I didn't know about the check.attributes argument in the all.equal function, but honestly might be very useful in other checks throughout the package.

@sou412
Copy link
Collaborator Author

sou412 commented Sep 8, 2020

Yes, this is one approach, but I worry that we would have to check all possible names. What about using something like the following:

tt <- table(resume$sex, resume$call)
jj <- table(sex = resume$sex, call = resume$call)
all.equal(tt, jj, check.attributes = FALSE)

We would still have to check both ordering. I didn't know about the check.attributes argument in the all.equal function, but honestly might be very useful in other checks throughout the package.

This looks much better. I didn't find the use of table() in the following two tutorials, but this way seems more robust and applicable to other settings.

mattblackwell pushed a commit that referenced this pull request Sep 16, 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

Successfully merging this pull request may close these issues.

Checking tables should be robust to named arguments
2 participants