pack.data.frame: Capture Scalar Column Metadata as Column Attributes

View source: R/pack.R

pack.data.frameR Documentation

Capture Scalar Column Metadata as Column Attributes

Description

Captures scalar column metadata (row values) as column attributes. Excises rows with non-missing values of meta, converting column values to column attributes. Afterward, column classes are re-optimized using default behavior of read.table. It is an error if meta is not in names(x).

Usage

## S3 method for class 'data.frame'
pack(
  x,
  meta = getOption("meta", "meta"),
  as.is = TRUE,
  attributes = TRUE,
  na.rm = TRUE,
  ...
)

Arguments

x

data.frame

meta

column in x giving names of attributes

as.is

passed to type.convert

attributes

preserve non-standard attributes (ignores names, row.names, class)

na.rm

if TRUE, NA values (presumably structural) will not be assigned as column attributes.

...

ignored arguments

Value

data.frame

See Also

Other pack: pack(), unpack.data.frame(), unpack()

Other methods: axislabel.data.frame(), boxplot.data.frame(), categorical.data.frame(), corsplom.data.frame(), densplot.data.frame(), metaplot.data.frame(), plot.metaplot_gtable(), print.metaplot_gtable(), scatter.data.frame(), unpack.data.frame()

Examples

foo <- data.frame(head(Theoph))
attr(foo$Subject, 'label') <-  'subject identifier'
attr(foo$Wt, 'label') <-  'weight'
attr(foo$Dose, 'label') <-  'dose'
attr(foo$Time, 'label') <-  'time'
attr(foo$conc, 'label') <-  'concentration'
attr(foo$Subject, 'guide') <-  '////'
attr(foo$Wt, 'guide') <-  'kg'
attr(foo$Dose, 'guide') <-  'mg/kg'
attr(foo$Time, 'guide') <-  'h'
attr(foo$conc, 'guide') <-  'mg/L'
unpack(foo, pos = 1)
unpack(foo, pos = 2)
unpack(foo, pos = 3)
unpack(foo, pos = 4)
bar <- unpack(foo)
pack(bar)
attributes(pack(bar)$Subject)

bergsmat/metaplot documentation built on Feb. 21, 2024, 1:18 p.m.