Last data update: 2014.03.03

R: ascii2char: Converting ASCII encoded values to character...
ascii2charR Documentation

ascii2char: Converting ASCII encoded values to character values.

Description

ascii2char calculates character representations for given phred values. char2ascii returns phred values for given ASCII encoded representations (the reverse transformation of ascii2char).

Usage

ascii2char(x, multiple=FALSE)
char2ascii(c)

Arguments

x

numeric. Vector with ASCII values. All values must be in 1:255. Other values produce an error.

multiple

logical. For 'FALSE' (the default), all characters are combined into one single string (i.e. a character vector of length 1). For 'TRUE', single characters are combined into a vector.

c

character. Vector of length 1 (Longer vectors will generate Warnings).

Details

The functions are only wrappers for convenience. char2ascii is defined as strtoi(charToRaw(c), base = 16L). ascii2char is defined as rawToChar(as.raw(x), multiple).

Value

ascii2char returns character. char2ascii returns integer.

Author(s)

Wolfgang Kaisers

References

Ewing B, Green P Base-Calling of Automated Sequencer Traces Using Phred. II. Error Probabilities Genome Research 1998 8(3): 186-194

See Also

getPhredTable

Examples

ascii2char(97:101, multiple=FALSE)
ascii2char(97:101, multiple=TRUE)
char2ascii("abcde")
char2ascii(paste("a", "b", "c", collapse=""))
ascii2char(char2ascii("abcde"))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(seqTools)
Loading required package: zlibbioc
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/seqTools/ascii2char.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ascii2char
> ### Title: ascii2char: Converting ASCII encoded values to character values.
> ### Aliases: ascii2char char2ascii
> ### Keywords: ascii2char
> 
> ### ** Examples
> 
> ascii2char(97:101, multiple=FALSE)
[1] "abcde"
> ascii2char(97:101, multiple=TRUE)
[1] "a" "b" "c" "d" "e"
> char2ascii("abcde")
[1]  97  98  99 100 101
> char2ascii(paste("a", "b", "c", collapse=""))
[1] 97 32 98 32 99
> ascii2char(char2ascii("abcde"))
[1] "abcde"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>