specification.data.frame {spec} | R Documentation |
Make a Specification for a Data Frame
Description
Makes a specification for data.frame. Creates a template based on the data.frame. Uses column names for labels where columns do not have a label attribute. Factors will be encoded. numerics will be rounded to digits
and like integers will be expressed as ranges in guide
column. Integers and character with less than or exactly tol
unique values will be encoded.
Usage
## S3 method for class 'data.frame'
specification(x, tol = 10, digits = 20, ...)
Arguments
x |
object |
tol |
integer |
digits |
integer |
... |
passed arguments |
Value
spec data.frame with columns as follows.
- column
Column name.
- label
A descriptive label. Save and edit as necessary using external tool.
- guide
A guide to interpretation. NA for arbitrary character; range [low:high] for integer and numeric; an encoding e.g. //0/no//1/yes// for factor-like items ... save and edit factor labels as necessary using external tool.
For numeric ranges you can add text, such as units. E.g. if default guide is '[0:100]' you can edit to give 'mg [0:100]'. Or you can just substitute 'mg'.
guidetext
extracts just the character portion, andmatches
enforces the numeric range.- required
An R expression that can be coerced to logical. TRUE means item cannot be NA.
- comment
Arbitrary comment, e.g. derivation of the item given by
column
.
See Also
link{read.spec}
write.spec
respecify.character
write.spec
matches
Other specification:
specification.comment()
,
specification.default()
,
specification()
Examples
data(drug)
file <- tempfile()
spec <- specification(drug, tol = 3)