Skip to contents

This function is used as part of the input of many functions, to determine whether the input is text of whether it is code. All such functions use it via an input parameter named input_is_code, which is set by default to the value returned from this function. That value can always be over-ridden by specifying a fixed value of either TRUE or FALSE for input_is_code.

Values from this function are only approximate, and there are even software packages which can give false negatives and be identified as prose (like rOpenSci's "geonames" package), and prose which may be wrongly identified as code.

Usage

text_is_code(txt)

Arguments

txt

Single input text string

Value

Logical value indicating whether or not txt was identified as code.

Examples

txt <- "Some text without any code"
text_is_code (txt)
#> [1] FALSE
txt <- "this_is_code <- function (x) { x }"
text_is_code (txt)
#> [1] TRUE