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

as.numeric-methodsR Documentation

Coerces a Dna object to a numeric matrix

Description

Converts a character matrix to a numeric matrix.

Usage

## S4 method for signature 'Dna'
as.numeric(x)

Arguments

x

an object of class Dna.

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.

Value

returns a numeric matrix.

Methods

signature(x = "Dna")

coerces a Dna object to a numeric matrix.

Examples

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)


haplotypes documentation built on July 26, 2023, 5:22 p.m.