A character array is a sequence of characters, just as a numeric array is a sequence of numbers. A typical use is to store a short piece of text as a row of characters in a character vector.
Methods (by class)
- char(character): Converting a character vector
- char(array): Converting a character array
Examples
char("Hi!")
#> [1] "Hi!"
char(matrix(letters, 2))
#> , , 1
#> 
#>      [,1]
#> [1,] "a" 
#> [2,] "b" 
#> 
#> , , 2
#> 
#>      [,1]
#> [1,] "c" 
#> [2,] "d" 
#> 
#> , , 3
#> 
#>      [,1]
#> [1,] "e" 
#> [2,] "f" 
#> 
#> , , 4
#> 
#>      [,1]
#> [1,] "g" 
#> [2,] "h" 
#> 
#> , , 5
#> 
#>      [,1]
#> [1,] "i" 
#> [2,] "j" 
#> 
#> , , 6
#> 
#>      [,1]
#> [1,] "k" 
#> [2,] "l" 
#> 
#> , , 7
#> 
#>      [,1]
#> [1,] "m" 
#> [2,] "n" 
#> 
#> , , 8
#> 
#>      [,1]
#> [1,] "o" 
#> [2,] "p" 
#> 
#> , , 9
#> 
#>      [,1]
#> [1,] "q" 
#> [2,] "r" 
#> 
#> , , 10
#> 
#>      [,1]
#> [1,] "s" 
#> [2,] "t" 
#> 
#> , , 11
#> 
#>      [,1]
#> [1,] "u" 
#> [2,] "v" 
#> 
#> , , 12
#> 
#>      [,1]
#> [1,] "w" 
#> [2,] "x" 
#> 
#> , , 13
#> 
#>      [,1]
#> [1,] "y" 
#> [2,] "z" 
#>