Mashed_table: Mash Tables

Description Usage Arguments Value See Also Examples

View source: R/Mashed_table.R

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

1
2
3
4
5
6
7
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_table() only: data.frames with the same row and column count. Elements of (...) can be named, but the name must differ from the argument names of this function.

mash_method

either "row" or "col". Should the tables be mashed together with alternating rows or with alternating columns?

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.

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 xlsx. if insert_blank_row == TRUE, height of the inserted row, else height of the top row of each mash-group.

meta

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

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.

tables

mash_table_list() only: a list of data.frames as described for (...)

Value

a Mashed_table: a list of data.tables 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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

tatoo documentation built on May 1, 2019, 9:52 p.m.