Learn R Programming

haplotypes (version 1.1.3.1)

as.numeric-methods: Coerces a Dna object to a numeric matrix

Description

Converts a character matrix to a numeric matrix.

Usage

# S4 method for Dna
as.numeric(x)

Value

returns a numeric matrix.

Arguments

x

an object of class Dna.

Methods

signature(x = "Dna")

coerces a Dna object to a numeric matrix.

Details

Function as.numeric() coerces the character matrix in the slot sequence to a numeric matrix. Lower or upper case characters "?","A","C","G","T","-" are converted to integers 0,1,2,3,4,5, respectively.

Examples

Run this code
x<-matrix(c("?","A","C","g","t","-","0","1","2","3","4","5"),4,6)
rownames(x)<-c("seq1","seq2","seq3","seq4") 
x<-as.dna(x)
# original character matrix 
as.matrix(x) 

## Coercing a 'Dna' object to a numeric matrix.
# numeric matrix
as.numeric(x)

Run the code above in your browser using DataLab