Skip to contents

This method turns its argument x, or at least part of the information in it, into a character vector.

Usage

as_character(x, ...)

# S3 method for default
as_character(x, ...)

# S3 method for re
as_character(x, ...)

# S3 method for tokens
as_character(x, ...)

Arguments

x

Object to coerce to character

...

Additional arguments

Value

Object of class character

Examples

(tks <- tokenize("The old man and the sea."))
#> Token sequence of length 6
#> idx token
#> --- -----
#>   1   the
#>   2   old
#>   3   man
#>   4   and
#>   5   the
#>   6   sea
as_character(tks) # turn 'tokens' object into character vector
#> [1] "the" "old" "man" "and" "the" "sea"
as.character(tks) # alternative approach
#> [1] "the" "old" "man" "and" "the" "sea"

as_character(1:10)
#>  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"
as.character(1:10)
#>  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"

regex <- re("(?xi) ^ .*")
as_character(regex) # turn 're' object into character vector
#> [1] "(?xi) ^ .*"
as.character(regex) # alternative approach
#> [1] "(?xi) ^ .*"