Search code examples
rstringvectorassert

R package 'checkmate': testString is successful for vector but not assertString, why?


I am currently reading the documentation for checkmate package and I find an issue when dealing with a vector of strings.

testString(letters)
#FALSE
assertString(letters)
#Error in assertString(letters) : 
#Assertion on 'letters' failed: Must have length 1.

It seems that assertString does not support test on vectors. Why is that? Any idea is welcome.


Solution

  • The documentation in assertString states that "a string is defined as a character scalar." The function you are seeking is assertCharacter.

    assertString is just a shortcut for assettCharacter (x, len =1)