mash_table {tatoo} | R Documentation |
Mash Tables
Description
mash_tables()
makes it easy to put together multidimensional
tables from data.frames
with the same number of rows and columns. You
can mash tables together with either alternating rows or columns.
Usage
mash_table(
...,
mash_method = "row",
id_vars = NULL,
insert_blank_row = FALSE,
sep_height = 24,
meta = NULL,
rem_ext = NULL
)
mash_table_list(
tables,
mash_method = "row",
id_vars = NULL,
insert_blank_row = FALSE,
sep_height = 24,
meta = NULL,
rem_ext = NULL
)
Arguments
... |
|
mash_method |
either |
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
|
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. |
sep_height |
Only has an effect when exporting to |
meta |
A TT_meta object. if supplied, output will also be a Tagged_table. |
rem_ext |
|
tables |
|
Value
a Mashed_table
: a list
of data.table
s with additional
mash_method
, insert_blank_row
and sep_height
attributes, that
influence how the table looks when it is printed or exported.
See Also
Attribute setters: mash_method<-
Other Tatoo tables:
comp_table()
,
stack_table()
,
tag_table()
,
tatoo_table()
Examples
df_mean <- data.frame(
Species = c("setosa", "versicolor", "virginica"),
length = c(5.01, 5.94, 6.59),
width = c(3.43, 2.77, 2.97)
)
df_sd <- data.frame(
Species = c("setosa", "versicolor", "virginica"),
length = c(0.35, 0.52, 0.64),
width = c(0.38, 0.31, 0.32)
)
# Mash by row
mash_table(df_mean, df_sd)
# Species length width
# 1: setosa 5.01 3.43
# 2: setosa 0.35 0.38
# 3: versicolor 5.94 2.77
# 4: versicolor 0.52 0.31
# 5: virginica 6.59 2.97
# 6: virginica 0.64 0.32
# Mash by column
mash_table(
df_mean, df_sd,
mash_method = 'col',
id_vars = 'Species'
)
# Species Species length length width width
# 1: setosa setosa 5.01 0.35 3.43 0.38
# 2: versicolor versicolor 5.94 0.52 2.77 0.31
# 3: virginica virginica 6.59 0.64 2.97 0.32
# Use the id_vars argument to prevent undesired dpulicated columns,
# and name the input data.frames to get multi-col headings.
mash_table(
mean = df_mean, sd = df_sd,
mash_method = 'col',
id_vars = 'Species'
)
# .......... ..length... ...width...
# 1 Species mean sd mean sd
# 2 setosa 5.01 0.35 3.43 0.38
# 3 versicolor 5.94 0.52 2.77 0.31
# 4 virginica 6.59 0.64 2.97 0.32