TidyTabularData: Create a Tidy Table or Vector

View source: R/tidytabulardata.R

TidyTabularDataR Documentation

Create a Tidy Table or Vector

Description

Creates tables that are ensured to be in a tidy format. Output is guaranteed to always have row and column names and there is special handling of arrays and tables from Q.

Usage

TidyTabularData(
  x,
  date = FALSE,
  row.names.to.remove = NULL,
  col.names.to.remove = NULL,
  transpose = FALSE,
  split = "[;,]",
  hide.empty.rows.and.columns = FALSE,
  ...
)

Arguments

x

Numeric matrix or vector; should be named, but if names are not present they will be created in the output

date

Optional vector of dates, which if supplied, will be used for the row names of the returned table; must be unique and have the same length or number of rows of x; will overwrite any existing row names present in x; the default, FALSE, means that no dates are present in the data; a value of NULL indicates that dates are contained in x.

row.names.to.remove

Character vector or delimited string of row labels specifying rows to remove from the returned table.

col.names.to.remove

Character vector or delimited string of column labels specifying columns to remove from the returned table

transpose

logical; if TRUE the table will be transposed before being returned

split

Character delimiter to split row.names.to.remove and col.names.to.remove on. Default is to split on either of "," or ";". Assumed to be a regular expression; see strsplit.

hide.empty.rows.and.columns

Logical; if TRUE empty rows and columns will be removed from the data. Empty here meaning that a row or column contains all NA values, or in the case of percentages, that a row or column contains only 0's.

...

Additional arguments passed to ParseUserEnteredTable in the case that x has character entries.

Details

If x is not a numeric vector or matrix, an attempt will be made to coerce it to one using AsTidyTabularData.

If a named vector is created from x, then row.names.to.remove and col.names.to.remove will be combined (using base:union) to determine entries to remove.

Value

A named matrix or vector; a tidy version of x.

Note

If transpose == TRUE, then the table is transposed before rows and columns are removed, so row.names.to.remove should be specified according to the rownames of the transposed table, as should col.names.to.remove

See Also

AsTidyTabularData, HideEmptyRowsAndColumns, RemoveRowsAndOrColumns


NumbersInternational/flipTables documentation built on Feb. 26, 2024, 6:42 a.m.