Learn R Programming

ribiosUtils (version 1.7.7)

asNumMatrix: Convert string-valued data frame or matrix into a numeric matrix

Description

Convert string-valued data frame or matrix into a numeric matrix

Usage

asNumMatrix(x)

Value

A numeric matrix with the same dimension

Arguments

x

A data.frame or matrix, most likely with string values

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

Examples

Run this code

testDf <- data.frame(a=c("2.34", "4.55"), b=c("7.33", "9.10"))
asNumMatrix(testDf)

testMatrix <- matrix(c("2.34", "4.55", "9E-3","-2.44", "7.33", "9.10"), nrow=2)
asNumMatrix(testMatrix)

Run the code above in your browser using DataLab