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

How to use checkCharacter(), arg names = ? #249

Open
vertesy opened this issue Nov 13, 2023 · 2 comments
Open

How to use checkCharacter(), arg names = ? #249

vertesy opened this issue Nov 13, 2023 · 2 comments

Comments

@vertesy
Copy link

vertesy commented Nov 13, 2023

Hey,

first off, thanks for the great package!

In checkCharacter(), arg names = you write:

[character(1)] Check for names. See checkNamed for possible values. Default is “any” which performs no check at all. Note that you can use checkSubset to check for a specific set of names.

  • So am I supposed to use checkSubset() inside checkCharacter()? How?

Thank you for your time taken!

@tdeenes
Copy link
Contributor

tdeenes commented Nov 13, 2023

You seem to misunderstand what the manual says: the possible values for the names argument of checkCharacter are listed in ?checkNamed (see the type argument). So you can have sthing like:

checkCharacter(c(a = "A", b = "B"), names = "unique") # this passes
#checkCharacter(c(a = "A", b = "B"), names = "unnamed") # this fails

If you want to check for a specific set of names, you have to use checkSubset:

x <- c(a = "A", b = "B")
assert(
  checkCharacter(x),
  checkSubset(names(x), choices = base::letters),
  combine = "and"
)

@vertesy
Copy link
Author

vertesy commented Nov 13, 2023

Ah, thanks, especially for typing out the examples!!
clear now!

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