nacnudus / unpivotr

Unpivot complex and irregular data layouts in R
https://nacnudus.github.io/unpivotr/
Other
185 stars 19 forks source link

More informative error message for check_distinct() #15

Closed gregrs-uk closed 6 years ago

gregrs-uk commented 6 years ago

Previous:

Error in check_distinct(cells) : 
  dplyr::n_distinct(dplyr::select(cells, row, col)) == nrow(cells) is not TRUE

New:

Error: Row and column numbers must be distinct.
  Perhaps you meant to use a single sheet.
nacnudus commented 6 years ago

Thank you very much!

To pass the tests, change the error messages in the tests:

tests/testthat/test-behead.R
tests/testthat/test-enhead.R
tests/testthat/test-partition.R
tests/testthat/test-rectify.R

Also please add a bullet point referencing this pull request (#15) and your handle @gregrs-uk to NEWS.md. I've just incremented to a dev version, so you will need to rebase onto it first.

gregrs-uk commented 6 years ago

No problem. Thanks for the very useful package!

I've rebased on to your master branch, updated the relevant tests and NEWS.md, then forced a push.

FYI when I run test_dir('tests/testthat'), I get the following errors relating to concatenate(). Is this because it's not exported?

test-concatenate.R:4: error: concatenate() works on common datatypes
could not find function "concatenate"
1: expect_equal(concatenate(list(NULL, NA, TRUE)), c(NA, NA, TRUE)) at tests/testthat/test-concatenate.R:4
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))

test-concatenate.R:34: error: concatenate() factor features work
could not find function "concatenate"
1: expect_equal(concatenate(x), factor(c(NA, NA, "a", "b"))) at tests/testthat/test-concatenate.R:34
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))

test-concatenate.R:50: error: concatenate() handles all-null lists
could not find function "concatenate"
1: expect_equal(concatenate(x), x) at tests/testthat/test-concatenate.R:50
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))

test-concatenate.R:56: error: concatenate() handles timezones
could not find function "concatenate"
1: expect_equal(concatenate(list(x, y)), as.POSIXct(c("2018-01-01 01:00:00", "2018-04-01 01:00:00"), tz = "UTC")) at tests/testthat/test-concatenate.R:56
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))

I couldn't seem to run the tests using tests/testthat.R:

library(testthat)
library(unpivotr)

test_check("unpivotr")
#> Error: No tests found for unpivotr

Created on 2018-07-22 by the reprex package (v0.2.0).

nacnudus commented 6 years ago

Thanks, merged. I've never used test_dir() or test_check(). It works with devtools::check().

Possibly relevant if you want to dig into test_dir():

gregrs-uk commented 6 years ago

Thanks. devtools::test() also works so I think I'll use that rather than test_dir() in future.