R/expandColumn.R
expandColumn.RdSimilar 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.
expandColumn( data, colName, ..., rowidSource = NULL, rowidDest = NULL, idxDest = NULL, tempNameGenerator = mk_tmp_name_source("replyr_expandColumn") )
| 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. |
expanded data frame where each value of colName column is in a new row.
d <- data.frame(name= c('a','b')) d$value <- list(c('x','y'),'z') expandColumn(d, 'value', rowidDest= 'origRowId', idxDest= 'valueIndex')#> name origRowId valueIndex value #> 1 a 1 1 x #> 2 a 1 2 y #> 3 b 2 1 z