A px
object is the internal representation in R of a PC-Axis
file. As such, it contains both data and metadata.
The data to populate the px
object comes from x
, the
first argument of the function. If x
is an array, it needs
to have 'named dimnames
', i.e., its dimnames
attribute
needs to be a list with named entries.
x
can also be a molten data.frame
, i.e., each row contains a single
value and the remaining columns indicate the levels of the variables it refers to.
The ts names
will be used in STUB and HEDING keyword of px objects. The first
column of x
will be used as 'HEADING', and the rest, in reverse, order as 'STUB'.
There are two compatible methods to provide metadata information. The
first one is via skeleton.px
, a px
object whose metadata
(title, etc.) is to be recycled in the new object. In addition to
that, list.keys
can be used to pass metadata in key-value pairs
as shown in the examples below.
Metadata provided in list.keys
has priority over metadata
coming from skeleton.px
. Also, note that the metadata items
used to name the variables and their labels are neither extracted from
skeleton.px
nor px
but from the dimnames
attribute
of x
.
Note that the keywords 'HEADING', 'VALUES' and 'DATA', if present in skeleton.px
or
list.keys
, are ignored. Inconsistent 'CODES' in skeleton.px
will also be
ignored.
Few checks are made to guarantee that metadata keys conform to the PC-Axis standard.