qsslearnr icon indicating copy to clipboard operation
qsslearnr copied to clipboard

Add additional solution of table() to allow for naming col/row

Open sou412 opened this issue 4 years ago • 2 comments

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

sou412 avatar Sep 07 '20 21:09 sou412

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.

mattblackwell avatar Sep 07 '20 22:09 mattblackwell

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.

sou412 avatar Sep 08 '20 01:09 sou412