assertthat
assertthat copied to clipboard
is.scalar to include is.atomic?
Hi, the test for scalar evaluates also complex data types to true. For example
assertthat::is.scalar(list("foo"))
[1] TRUE
This was quite unexpected to me, because it is also documented together with the test for atomic data types.
Is there a rationale not to test for the given value to be atomic? Otherwise I would propose to test:
assertthat::is.scalar <- function (x) {
is.atomic(x) && length(x) == 1L
}
Thanks for your help, Manuel
Also
assertthat::is.scalar(data.frame(x = 1:10))
[1] TRUE
is unexpected