matches: Test the Correspondence between a Table and a Specification

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

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.

Usage

1
2
3
4
5
6
7
8
	## S3 method for class 'character'
x %matches% y, ...
	## S3 method for class 'data.frame'
x %matches% y, ...
	## S3 method for class 'keyed'
x %matches% y, ...
	## S3 method for class 'spec'
x %matches% y, ...

Arguments

x

object of dispatch

y

corresponding object

...

ignored

Details

matches returns TRUE if no exceptions are detected. It checks the following, and issues appropriate messages as necessary.

In short, the following are enforced: names, order, type, format, levels, ranges, and presence requirements.

Value

scalar logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 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))

metrumrg documentation built on May 2, 2019, 5:55 p.m.