Fix call to `duplicated()`
Closed this issue · 0 comments
maurolepore commented
Closes https://github.com/2DegreesInvesting/TiltDevProjectMGMT/issues/107
#45 fixed a bug in the article "Get started" and #57 fixed it in README.
It would be great to write a unit test to ensure the bug does never return.
# Good
duplicated(paste(company_name, postcode))
# Bad: The first argument of `duplicated()` is not `...` it is a single vector `x`
# See `?duplicated()`
duplicated(company_name, postcode)
One way to tackle this issue is to write a little helper function, use it in tests, then use it elsewhere (README, Get started).
duplicated_paste <- function(...) {
duplicated(paste(...))
}
You may fist write the wrong implementation and design a test that fails. The challenge is to figure out which data to use. Then fix the implementation and confirm the test passes.