Learn R Programming

replyr (version 0.2.0)

replyr_gather: Collect values found in gatherColumns as tuples

Description

Collect values found in gatherColumns as tuples naming which column the value came from (placed in measurementNameColumn) and value found (placed in measurementValueColumn). This is essentially a tidyr::gather, dplyr::melt, or anti-pivot.

Usage

replyr_gather(df, gatherColumns, measurementNameColumn, measurementValueColumn, useTidyr = FALSE, eagerCompute = FALSE)

Arguments

df
data item
gatherColumns
set of columns to collect measurements from
measurementNameColumn
new column to write measurement names to (original gatherColumns)
measurementValueColumn
new column to write measurement values to
useTidyr
if TRUE use tidyr instead of calculating on own (only works on local data types)
eagerCompute
if TRUE call compute on intermediate results

Value

data item

Examples

Run this code

d <- data.frame(
  index = c(1, 2, 3),
  info = c('a', 'b', 'c'),
  meas1 = c('m1_1', 'm1_2', 'm1_3'),
  meas2 = c('m2_1', 'm2_2', 'm2_3'),
  stringsAsFactors = FALSE)
replyr_gather(d,c('meas1','meas2'),'meastype','meas')
replyr_gather(d,c('meas1','meas2'),'meastype','meas',useTidyr=TRUE)

Run the code above in your browser using DataLab