revchar {Maeswrap}R Documentation

Reverse a character string.

Description

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

Usage

revchar(x)

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

## 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)

[Package Maeswrap version 1.7 Index]