as_Composite_table {tatoo}R Documentation

Coerce to Composite Table

Description

Converts other R objects to Composite_tables by automatically creating multi-column names from the properties of the objects.

Usage

as_Composite_table(x, ...)

## S3 method for class 'Mashed_table'
as_Composite_table(
  x,
  id_vars = attr(x, "id_vars"),
  meta = attr(x, "meta"),
  ...
)

## S3 method for class 'data.frame'
as_Composite_table(x, sep = ".", reverse = FALSE, ...)

is_Composite_table(x, ...)

Arguments

x

Any R object.

...

Ignored

id_vars

If id_vars is specified, the tables will be combined using merge() on the columns specified in id_vars, otherwise the tables will be combined with cbind().

meta

a TT_meta object. If specified, the resulting Composite_table will be wrapped in a Tagged_table.

sep

a scalar character. Separator in the column names of x that separates the column name from the multi-column name.

reverse

logical. if FALSE the part after the last occurrence of sep will be used as multiname, if TRUE the part before will be used.

Value

as_Composte_table() returns a Composite_table

is_Composite_table returns TRUE if its argument is a Composite_table and FALSE otherwise.

Examples


mash_table(
  head = head(cars),
  tail = tail(cars),
  mash_method = 'col'
)


as_Composite_table(data.frame(
  apple.fruit = 1,
  kiwi.fruit = 2,
  dog.animal = 1,
  black.cat.animal = 2,
  parrot.animal = 3
))


[Package tatoo version 1.1.2 Index]