Description Usage Arguments Details Value Author(s) References See Also Examples
The %matches%
operators test whether a data frame matches its
corresponding spec
, and vice versa. The character method treats
x as the name of a csv-encoded file (na strings '', ‘.’, and NA),
and coerces y using as.spec
. The
latter in turn should be a single file name for a spec, if character.
The method for spec
treats y as the data frame. The real work
is done by the keyed
method.
1 2 3 4 5 6 7 8 |
x |
object of dispatch |
y |
corresponding object |
... |
ignored |
matches
returns TRUE if no exceptions are detected. It checks the
following, and issues appropriate messages as necessary.
Column names must match.
Column order must match.
Column type must match; numerics can be typed as integer if they have no trailing decimal places.
Columns of type ‘datetime’ must be coercible using the declared format string.
Each element of a column with an encoded guide element must be one of the encoded levels, or NA.
If the guide element ends with some variant of the range specifier – (0, 30) [0, 30] etc. – then all non-missing values must fall in that range.
Each element of a column must be defined (not NA) wherever the corresponding ‘required’ expression evaluates to TRUE.
In short, the following are enforced: names, order, type, format, levels, ranges, and presence requirements.
scalar logical
Tim Bergsma
http://metrumrg.googlecode.com
as.spec
specfile
specification
codes
encode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | test <- Theoph
names(test) <- c('SUBJ','WT','DOSE','DATETIME','DV')
test$DATETIME <- as.mDateTime(
as.mDate('2013-10-17'),
as.mTime(as.second(round(as.minute(as.second(as.hour(test$DATETIME))))))
)
head(test)
test <- sort(as.keyed(test, c('SUBJ','DATETIME')))
test <- aug(test[!duplicated(test$SUBJ),], AMT=DOSE,DOSE=NULL,EVID=1,SEQ=0,DV=NA) +
aug(test,DOSE=NULL,EVID=0,SEQ=1)
test <- as.nm(test)
summary(test)
head(test)
for(col in c('TIME','TAFD','TAD')) test[[col]] <- round(test[[col]], 5)
spec <- specification(test)
summary(spec)
spec[1,1] <- paste(' " ',spec[1,1],' " ') # will be stripped by read.spec
spec[1,1]
write.nm(test, 'test.csv')
write.spec(spec,'test.spec')
spec <- read.spec('test.spec')
spec[1,1]
labels(as.spec('test.spec'))
codes(as.spec('test.spec'))
decodes(as.spec('test.spec'))
guidetext(as.spec('test.spec'))
test %matches% spec
test %matches% 'test.spec'
'test.csv' %matches% spec
'test.csv' %matches% 'test.spec'
spec %matches% test
spec %matches% 'test.csv'
as.pdf(as.define(spec),stem = 'test')
unlink('test.csv')
unlink('test.spec')
unlink('test.pdf')
head(respecify(spec, data=test))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.