b_gather: base gather

Description Usage Arguments Value Author(s) See Also Examples

View source: R/gather.R

Description

base gather mimics basic functionality of tidyr::gather

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
b_gather(
  data,
  key = "key",
  value = "value",
  columns = NULL,
  regex = FALSE,
  ...,
  na.rm = FALSE,
  convert = FALSE
)

Arguments

data

data.frame

key

character, name of new key column, Default: 'key'

value

character, name of new value column, Default: 'value'

columns

column names or indicies or regex of them to gather, Default: NULL

regex

boolean, indicates of columns is to be treated as a regular expression, Default: FALSE

...

parameters to pass to grep

na.rm

boolean, apply na.omit to value column, Default: FALSE

convert

boolean, apply type.convert to key column, Default: FALSE

Value

data.frame

Author(s)

Jonathan Sidi

See Also

type.convert

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
mini_iris <- iris[c(1, 51, 101), ]

# gather Sepal.Length, Sepal.Width, Petal.Length, Petal.Width

b_gather(mini_iris, key = 'flower_att', value = 'measurement',
columns = c('Sepal.Length', 'Sepal.Width', 'Petal.Length', 'Petal.Width'))

b_gather(mini_iris, key = 'flower_att', value = 'measurement',
columns = 1:4)

b_gather(mini_iris, key = 'flower_att', value = 'measurement',
columns = -5)

b_gather(mini_iris, key = 'flower_att', value = 'measurement',
columns = '^(Sepal|Petal)',regex = TRUE)

yonicd/bplyr documentation built on Feb. 24, 2020, 2 p.m.