vcollapse: Collapse row contents of a data.frame or matrix into single...

Description Usage Arguments Details Author(s) Examples

View source: R/vcollapse.R

Description

Similar to python zip, 'vzip' takes input vectors and merges them together by their input order and index. A simple example is two numeric vectors, A = c(1,1,1) and B = c(2,2,2). The output of vzip(A,B) would simply be a single vector of c(1,2,1,2,1,2). Any number of vectors can be input, but each input vector must be of the same length. Output vector class depends on input vector consensus.

Usage

1
2
vcollapse(d)
vcollapse(d, sep = "-", fill = "NA")

Arguments

d

data.frame or matrix or object coercible to a matrix. Row contents will be combined into a single output vector.

sep

character used to separate collapsed contents.

fill

character used to fill empty values within the coerced object.

Details

vcollapse returns a single vector from input data.frame or matrix where row contents have been combined or collapsed, as with 'paste(..., collaspe = "")'.

Author(s)

Christopher Nobles, Ph.D.

Examples

1
2
3
4
5
6
7
df <- data.frame(
  "A" = letters[1:5],
  "B" = 3:7,
  "C" = LETTERS[2:6])
vcollapse(df)
vcollapse(df, sep = "-")
vcollapse(df, sep = "-", fill = "z")

cnobles/gintools documentation built on Aug. 22, 2019, 10:36 a.m.