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

is.scalar to include is.atomic? #51

Open
landesfeind opened this issue Aug 28, 2018 · 1 comment
Open

is.scalar to include is.atomic? #51

landesfeind opened this issue Aug 28, 2018 · 1 comment

Comments

@landesfeind
Copy link

landesfeind commented Aug 28, 2018

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

@jfkingiii
Copy link

Also

assertthat::is.scalar(data.frame(x = 1:10))
[1] TRUE

is unexpected

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

No branches or pull requests

2 participants