Learn R Programming

FastUtils (version 0.2.1)

getChar: Get a Character at a Specific Index

Description

This function retrieves a character at a specific index from a string.

Usage

getChar(x, index)

Value

The character at the specified index.

Arguments

x

A character string.

index

The index of the character to retrieve. If it is length 1, then the same character is retrieved for all elements of x. Otherwise, if it is the same length as x, then the character at each index is retrieved.

Examples

Run this code
# Get the character at index 2
getChar("hello", 2)

Run the code above in your browser using DataLab