revchar: Reverse a character string.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Reverses the characters in a character string, unless a vector is supplied, in which case reverses the element of the vector.

Usage

1

Arguments

x

A character vector (typically of length 1).

Details

When a character vector of length > 1 is provided, reverses the elements of the vector, not the characters itself.

Value

A vector.

Author(s)

Remko Duursma

References

None.

See Also

rev.default,substr,strsplit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# Take a substring, counting from the end:
substrfromend <- function(x,start,stop)revchar(substr(revchar(x),start,stop))
substrfromend('filename.txt', 1,3)

# Check if a word is a palindrome:
s <- 'saippuakivikauppias'
s == revchar(s)

# A semordnilap:
cat('I am so stressed, I need to eat', revchar('stressed'),'\n')

## End(Not run)

Maeswrap documentation built on May 2, 2019, 7:58 a.m.