| 1 |
\name{rotn} |
| 2 |
\alias{rotn} |
| 3 |
\title{Generalized Rot13 Character Translation (Rotation)} |
| 4 |
\description{ |
| 5 |
Compute generalized \sQuote{rot13} character translations or |
| 6 |
\dQuote{rotations} |
| 7 |
|
| 8 |
In the distant past, considered as poor man's encryption, such |
| 9 |
rotations are way too poor nowadays and provided mainly for didactical |
| 10 |
reasons. |
| 11 |
} |
| 12 |
\usage{ |
| 13 |
rotn(ch, n = 13) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{ch}{a \code{\link{character}} vector; often a string (of length 1).} |
| 17 |
\item{n}{an integer in \eqn{\{1\dots26\}}{{1...26}}; the default is |
| 18 |
particularly useful.} |
| 19 |
} |
| 20 |
\value{ |
| 21 |
a character as \code{ch}, but with each character (which |
| 22 |
belongs to \code{\link{letters}} or \code{\link{LETTERS}} |
| 23 |
\dQuote{rotated} by \code{n} (positions in the alphabet). |
| 24 |
} |
| 25 |
\author{Martin Maechler} |
| 26 |
\details{ |
| 27 |
Note that the default \code{n = 13} makes \code{rotn} into |
| 28 |
a function that is its own inverse. |
| 29 |
|
| 30 |
Written after having searched for it and found |
| 31 |
\code{seqinr::rot13()} which was generalized and rendered more |
| 32 |
transparently to my eyes. |
| 33 |
} |
| 34 |
\seealso{ |
| 35 |
\code{\link{rot2}}, a completely different rotation (namely in the |
| 36 |
plane aka \eqn{R^2}). |
| 37 |
} |
| 38 |
\examples{ |
| 39 |
rotn(c("ABC", "a","b","c"), 1) |
| 40 |
rotn(c("ABC", "a","b","c"), 2) |
| 41 |
rotn(c("ABC", "a","b","c"), 26) # rotation by 26 does not change much |
| 42 |
|
| 43 |
(ch <- paste("Hello", c("World!", "you too"))) |
| 44 |
rotn(ch) |
| 45 |
rotn( rotn(ch ) ) # rotn(*, 13) is its own inverse |
| 46 |
} |
| 47 |
\keyword{manip} |