Learn R Programming

replyr (version 1.0.5)

expandColumn: Expand a column of vectors into one row per value of each vector.

Description

Similar to tidyr::unnest but lands rowids and value ids, and can work on remote data sources. Fairly expensive per-row operation, not suitable for big data.

Usage

expandColumn(data, colName, ..., rowidSource = NULL, rowidDest = NULL,
  idxDest = NULL,
  tempNameGenerator = mk_tmp_name_source("replyr_expandColumn"))

Arguments

data

data.frame to work with.

colName

character name of column to expand.

...

force later arguments to be bound by name

rowidSource

optional character name of column to take row indices from (rowidDest must be NULL to use this).

rowidDest

optional character name of column to write row indices to (must not be an existing column name, rowidSource must be NULL to use this).

idxDest

optional character name of column to write value indices to (must not be an existing column name).

tempNameGenerator

temp name generator produced by wrapr::mk_tmp_name_source, used to record dplyr::compute() effects.

Value

expanded data frame where each value of colName column is in a new row.

Examples

Run this code
# NOT RUN {

d <- data.frame(name= c('a','b'))
d$value <- list(c('x','y'),'z')
expandColumn(d, 'value',
             rowidDest= 'origRowId',
             idxDest= 'valueIndex')


# }

Run the code above in your browser using DataLab