Learn R Programming

metaplot (version 0.2.7)

pack.data.frame: 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 data.frame
pack(x, meta = getOption("meta", "meta"), as.is = TRUE,
  ...)

Arguments

x

data.frame

meta

column in x giving names of attributes

as.is

passed to read.table

...

ignored arguments

Value

data.frame

data.frame

See Also

unpack.data.frame

Other pack: pack.folded, pack, unpack.data.frame

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab