Skip to content

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

Open

Description

@vertesy

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!

Activity

  1. tdeenes commented on Nov 13, 2023

    @tdeenes
    Contributor

    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"
    )
    
  2. vertesy commented on Nov 13, 2023

    @vertesy
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions