Cipher-class | R Documentation |
"Cipher"
The Cipher
class is used to change between different alphabets
(and so behaves as a simple substitution cipher). The Cipher
function
creates a new object of the Cipher
class.
Cipher(sampleText, split = "-", extras = c("-" = ":", "?" = "?"))
encode(cipher, text)
decode(cipher, text)
sampleText |
A character vector that contains all symbols you want to be able to transliterate. Duplicate symbols are automatically removed. |
split |
A single character used to split words into symbols. Defaults to a hyphen for our applications. |
extras |
Additional characters to be added for reverse tranlsiteration, since they may appear as the results of alignments in consensus sequences. |
cipher |
An object of the |
text |
A character vector of words to be transliterated. |
The Cipher
function returns a new object of the Cipher
class. The encode
and decode
functions return character
vectors that are the same size as their input text
parameters.
Objects should be defined using the Cipher
constructor. You
typically pass in a character vector of "words" that contain all the
symbols that are contained in the text to be translated (i.e., encoded
and decoded) between languages. A standard target alphabet is created
along with forward and reverse transliteration rules.
forward
:A named character vector.
reverse
:A named character vector.
bytes
:The number of bytes used to encode each 'character' in the input test. Text with more than 72 unique characters use a two-byte encoding, which is enough for languages with up to 26*72 = 1872 characters.
Attempting to manipulate a Cipher
object using text containing
NAs, missing values, or previously unknown symbols will result in an error.
Kevin R. Coombes <krc@silicovore.com>
motif <- "0-50-74-0-50-74-25-26-35"
alfa <- Cipher(motif)
alfa
en <-encode(alfa, motif)
en
de <- decode(alfa, en)
de
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.