fuse: Fuse multiple columns into one

Description Usage Arguments Note See Also Examples

Description

fuse is a more flexible version of unite from package tidyr.

Usage

1
2
3
4
5
6
7
8
9
fuse(.data, col, ..., fun = concat0, remove = TRUE)

fuse_(.data, col, from, fun = concat0, remove = TRUE)

## S3 method for class 'data.frame'
fuse_(.data, col, from, fun = concat0, remove = TRUE)

## S3 method for class 'tbl_df'
fuse_(.data, col, from, fun = concat0, remove = TRUE)

Arguments

.data

A tbl or data.frame

col

character. (Bare) name of column to add

...

Specification of columns to fuse.

fun

function. The function to be applied (concat0 by default).

remove

logical. If TRUE (the default), remove input columns from output data frame.

from

character. A vector of the names of columns to fuse.

Note

This function has been inspired by the issue raised at https://github.com/tidyverse/tidyr/issues/203.

See Also

unite and unite_ from package tidyr;

concat0 from package bazar.

Examples

1
2
3
4
5
6
7
8
df <- data.frame(x = c(NA, "a", NA), 
                 y = c("b", NA, NA))
fuse(df, "z", x, y)

# To be compared with: 
tidyr::unite(df, "z", x, y, sep = "")
# The same
fuse(df, "z", x, y, fun = function(x) concat0(x, na.rm = FALSE))

paulponcet/lplyr documentation built on May 24, 2019, 10:32 p.m.