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

Description Usage Arguments Value See Also Examples

View source: R/pack.R

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

1
2
3
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)

metaplot documentation built on May 1, 2019, 10:17 p.m.