Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

masplit

masplit


Description

Split a matrix of delimited strings.

Usage

masplit(
  myMat,
  delim = ",",
  count = 0L,
  record = 1L,
  sort = 1L,
  decreasing = 1L
)

Arguments

myMat

a matrix of delimited strings (e.g., "7,2").

delim

character that delimits values.

count

return the count of delimited records.

record

which (1-based) record to return.

sort

should the records be sorted prior to selecting the element (0,1)?

decreasing

should the values be sorted decreasing (1) or increasing (0)?

Details

Split a matrix of delimited strings that represent numerics into numerics. The parameter count returns a matrix of integers indicating how many delimited records exist in each element. This is intended to help if you do not know how many records are in each element particularly if there is a mixture of numbers of records. The parameter record indicates which record to return (first, second, third, ...). The parameter sort indicates whether the records in each element should be sorted (1) or not (0) prior to selection. When sorting has been selected decreasing indicates if the sorting should be performed in a decreasing (1) or increasing (0) manner prior to selection.

Value

A numeric matrix

Examples

set.seed(999)
x1 <- round(rnorm(n=9, mean=10, sd=2))
x2 <- round(rnorm(n=9, mean=20, sd=2))
ad <- matrix(paste(x1, x2, sep=","), nrow=3, ncol=3)
colnames(ad) <- paste('Sample', 1:3, sep="_")
rownames(ad) <- paste('Variant', 1:3, sep="_")
ad[1,1] <- "9,23,12"
is.na(ad[3,1]) <- TRUE

ad
masplit(ad, count = 1)
masplit(ad, sort = 0)
masplit(ad, sort = 0, record = 2)
masplit(ad, sort = 0, record = 3)
masplit(ad, sort = 1, decreasing = 0)

vcfR

Manipulate and Visualize VCF Data

v1.12.0
GPL-3
Authors
Brian J. Knaus [cre, aut] (<https://orcid.org/0000-0003-1665-4343>), Niklaus J. Grunwald [aut] (<https://orcid.org/0000-0003-1656-7602>), Eric C. Anderson [ctb], David J. Winter [ctb], Zhian N. Kamvar [ctb] (<https://orcid.org/0000-0003-1458-7108>), Javier F. Tabima [ctb] (<https://orcid.org/0000-0002-3603-2691>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.