cmash: Mash R objects by Rows or Columns

View source: R/Mashed_table.R

rmashR Documentation

Mash R objects by Rows or Columns

Description

rmash() and cmash() are convenience function to mash data.frames together with a single command. They behave similar to cbind() and rbind(), just that the result will have have alternating rows/columns.

Usage

rmash(..., rem_ext = NULL, insert_blank_row = FALSE, meta = NULL)

cmash(
  ...,
  rem_ext = NULL,
  id_vars = NULL,
  suffixes = names(list(...)),
  meta = NULL
)

Arguments

...

either several data.frames, data.tables or a single Mashed_table. All data.frames must have the same number of columns.

rem_ext

character. For mash_table to work, the column names of all elements of dat must be identical. Sometimes you will have the situation that column names are identical except for a suffix, such as length and lenght.sd. The rem_ext option can be used to remove such suffixes.

insert_blank_row

Only if mashing rows: logical. Whether to insert blank rows between mash-groups. Warning: this converts all columns to character. Use with care.

meta

A TT_meta object. if supplied, output will also be a Tagged_table.

id_vars

Only if mashing columns: one ore more colnames of the tables to be mashed. If supplied, columns of both input tables are combined with merge(), otherwise cbind() is used.

suffixes

a character vector of length 2 specifying the suffixes to be used for making unique the names of columns.

Value

A data.table if any element of (...) is a data.table or Tatoo_table, or if meta is supplied; else a data.frame.

See Also

Mashed_table

Examples


dat1 <- data.frame(
  x = 1:3,
  y = 4:6
)

dat2 <- data.frame(
  x = letters[1:3],
  y = letters[4:6]
)

rmash(dat1, dat2)

#    x y
# 1: 1 4
# 2: a d
# 3: 2 5
# 4: b e
# 5: 3 6
# 6: c f

cmash(dat1, dat2)

#    x x y y
# 1: 1 a 4 d
# 2: 2 b 5 e
# 3: 3 c 6 f



tatoo documentation built on March 31, 2023, 8:16 p.m.