Learn R Programming

wrMisc (version 2.0.0)

extrNumericFromMatr: Extract numeric part of matrix or data.frame

Description

This function extracts numeric part of matrix or data.frame, removing remaining non-numeric elements if trimToData is set to TRUE. Note, that cropping entire lines where a (single) text element appeared may quickly reduce the overal content of the input data.

Usage

extrNumericFromMatr(
  dat,
  trimToData = TRUE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Value

This function reurns a matrix of numeric data

Arguments

dat

matrix (or data.frame) for extracting numeric parts

trimToData

(logical) default to remove (crop) lines and cols contributing to NA, non-numeric data is transfomed to NA

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of message(s) produced

Examples

Run this code
mat <- matrix(c(letters[1:7],14:16,LETTERS[1:6]),nrow=4,dimnames=list(1:4,letters[1:4]))
mat; extrNumericFromMatr(mat)
mat <- matrix(c(letters[1:4],1,"e",12:19,LETTERS[1:6]),nr=5,dimnames=list(11:15,letters[1:4]))
mat; extrNumericFromMatr(mat)

Run the code above in your browser using DataLab