This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/substr.html
substr {base}R Documentation

Extract Substrings from a Character Vector

Description

substr takes a character vector as an argument and returns a vector whose elements contain the substring starting with the character at position start up to the character at position stop. If start is larger than the string length then NA is returned. If stop is longer than start and error is signalled.

substring is compatible with S. For vector arguments, it expands the arguments cyclically.

Usage

substr(x, start, stop)
substring(text, first, last = 1000000)

See Also

strsplit, paste, nchar.

Examples

substr("abcdef",2,4)
substring("abcdef",1:6,1:6)
substr(rep("abcdef",4),1:4,4:5)
x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
all(substr(x, 2, 5) == substring(x, 2, 5)) #> TRUE
substr(x, 2, 5)
substring(x, 2, 4:6)

[Package base version 0.60 ]