charAt.String: Gets the character at given position

Description Usage Arguments Value Author(s) See Also Examples

Description

Gets the character at given position. First position has index 0.

Usage

1
2
## S3 method for class 'String'
charAt(this, index, ...)

Arguments

index

the index of the character.

Value

Returns one character (as a character string with length one).

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

See Also

*indexOf(), *lastIndexOf()

Examples

1
2
3
4
5
6
  s <- String("Hello world!")

  charAt(s, 0)               # "H"
  charAt(s, length(s)-1)     # "!"
  # charAt(s, length(s))     # ERROR: Index of bounds.
  charAt("Hello world!", 4)  # "o"

HenrikBengtsson/R.lang documentation built on May 8, 2019, 7:50 p.m.