gather.keep: Gather and Keep

View source: R/dthelper-data-wrangling.R

gather.keepR Documentation

Gather and Keep

Description

gather function that allows you to retain some of the existing columns

Usage

gather.keep(
  df,
  keep = NULL,
  var.to.gather = NULL,
  key = "key",
  value = "value"
)

Arguments

df

data.frame object

keep

Variables that shouldn't be gathered

var.to.gather

Variable that should be gathered. Defaults to all other variables apart from keep

key

Name of key variable after gathering

value

Name of value variable after gathering

Value

data.frame object

Examples

set.seed(100)
df <- data.frame(
      id = 1:10,
      v1_t1 = rnorm(10),
      v1_t2 = rnorm(10),
      v1_t3 = rnorm(10)
      )
gather.keep(df, keep = "id")


dennisteowh/dthelper documentation built on March 19, 2022, 11:42 a.m.