mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

testString - add case for charFrac #217

Closed iembry closed 2 years ago

iembry commented 2 years ago

Hi, for your testString function, will you also include character fractions to return TRUE for being a string?

Please see the example below:

xx <- as.character(fractional::fractional(1:9 / 12))

# > xx
# [1] 1/12 1/6  1/4  1/3  5/12 1/2  7/12 2/3  3/4

# > str(xx)
# 'charFrac' chr [1:9] "1/12" "1/6" "1/4" "1/3" "5/12" "1/2" "7/12" "2/3" ...

# > checkmate::testString(xx)
# [1] FALSE

Thank you in advance.

tdeenes commented 2 years ago

@iembry you want to use testCharacter, and not testString. testString tests if the input is a single-element character vector, so the result you get is expected (and correct).

mllg commented 2 years ago

The naming here is confusing, but in this case, that's base R's fault, not mine.

iembry commented 2 years ago

@tdeenes Thank you for letting me know. I will change it to testCharacter.