Strings: Head and Tail functions for Strings.

Description Usage Arguments Details Value Note Examples

Description

C++ implemetations of convenience functions for strings. All functions but strTake operate with O(1) memory.

strHead returns the first character of a string

strHeadLower returns the first character of a string coerced to lower case

strTail returns all but the first character of a string

strTake returns the first n characters of a string

strDrop returns all but the first n characters of a string

Usage

1
2
3
4
5

Arguments

s

a string object

n

the number of characters to take or drop

Details

A few convenient list operations, tailored to 8-bit-character strings.

Value

A character vector.

Note

While originally also implemented for performance reasons, the built-in substr function is usually faster due to the Call-overhead. At least for R 3.x onward the built-in functions should be preferred when performance is an issue. See the vignette for details.

Examples

1
2
3
4
5
strHead("Gnu")
strHeadLower("Gnu")
strTail("Gnu")
strTake("Gnus and Gnats",3)
strDrop("Gnus and Gnats",9)

Example output

[1] "G"
[1] "g"
[1] "nu"
[1] "Gnu"
[1] "Gnats"

Wmisc documentation built on Jan. 14, 2018, 1:04 a.m.