Description Usage Arguments Details Value Note Author(s) References See Also Examples
Objects of class nm are intended to support analysis using the software
NONMEM ((c), Icon Development Solutions). nm
gives a zero-row data.frame with
suitable columns and column classes (essentially, a template for dataset construction).
as.nm
and as.nm.data.frame
construct an
nm object from an existing object. The read and write methods are wrappers
for ‘.csv’ equivalents. read.nm
reconstitutes classes for flags,
DATETIME, and C.
1 2 3 4 5 |
x |
data.frame or nm |
na.strings |
passed to |
as.is |
passed to |
key |
passed to |
flags |
character vector naming colums to convert using |
... |
extra arguments, ignored or passed to |
file |
passed to |
na |
passed to |
row.names |
passed to |
quote |
passed to |
as.nm.data.frame
is the principal method that creates an nm classification. It
alone enforces all qualities of class nm. read.nm
is the only other function
that creates an nm classification; use with caution, as it does not enforce all qualities.
Just before as.nm.data.frame
returns, it calls as.nm
on each of
its columns: a non-operation (as.nm.default
) unless the user supplies specialized
classes and methods. Column-specific methods may make use of the passed argument
data
, which contains the data set itself. Any enforced or conditional outputs
(see column summary) have the column name as the first member of the class vector.
SUBJ
must be present and defined, even for commented records. ID is (re)calculated as as.numeric(factor(SUBJ))
.
C
(class: comment) will be created if not present.
NA
C
will be imputed FALSE
.
Every active (non-commented) source record should define exactly one of HOUR
or DATETIME
.
HOUR
is taken to represent relative accumulation of hours from arbitrary origin.
DATETIME
is understood as seconds, coercible to mDateTime
.
TIME
is calculated from either HOUR
or DATETIME
.
Definition (or not) of HOUR
vs. DATETIME
should be constant within subject (for active records).
SEQ
(class flag
) will be created if not present.
nm
will be keyed on SUBJ
, TIME
, and SEQ
. SEQ
determines sort order for rows with matching TIME
.
Result will be sorted.
TIME
will be relativized to earliest extant value, incl. those in comments.
TAFD
(time after first non-commented dose), TAD
(time since most recent non-commented dose), and LDOS
(amount of most recent non-commented dose) will be calculated if AMT
is present. TAD
and LDOS
are very literal: they return NA if no dose has been given yet, and will "remember" the time and amount of the most recent dose whether or not it is still conceptually relevant, given study design. If two doses are given at the same time, say in different compartments, LDOS reflects the first AMT with respect to sort order.
TAD
will consider ADDL
and II
if present.
NA
flags will be imputed as zero.
MDV
(missing dependent value) will be calculated if DV
is present, preserving non-NA MDV, if present.
resulting column order will lead with C
followed by key columns.
Column summary:
required inputs: SUBJ; HOUR or DATETIME
optional inputs: AMT, ADDL, II, DV
enforced outputs: SUBJ, ID, C, TIME, SEQ
conditional outputs: TAFD, TAD, LDOS, MDV
write.nm
is used for side effects. Others return an object with class
c('nm','keyed','data.frame')
.
Assembly chains, such as nm() + dose + samp | demo
, are no longer
supported. Nor are as.moot
and as.rigged
.
Tim Bergsma
http://metrumrg.googlecode.com
summary.nm
Ops.keyed
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 42 43 44 | ## Not run: metrumrgURL('example/project/script/assemble.pdf')
dose <- data.frame(
SUBJ = rep(letters[1:3], each = 2),
HOUR = rep(c(0,20),3),
AMT = rep(c(40,60,80), each = 2)
)
dose <- as.keyed(dose,key=c('SUBJ','HOUR'))
samp <- data.frame(
SUBJ = rep(letters[1:3], each = 4),
HOUR = rep(c(0,10,20,30),3),
DV = signif(rnorm(12),2) + 2
)
samp <- as.keyed(samp,key=c('SUBJ','HOUR'))
demo <- data.frame(
SUBJ = letters[2:5],
RACE = c('asian','white','black','other'),
SEX = c('female','male','female','male'),
WT = c(75, 70, 73, 68)
)
demo <- as.keyed(demo,key=c('SUBJ'))
meds <- as.keyed(
data.frame(
SUBJ=c('a','c'),
HOUR=c(0,15),
STOP=c(10,25),
C3A4=as.flag(c(1,1))
),
key=c('SUBJ','HOUR')
)
nm()
#nm() + dose
as.nm(dose)
as.nm(dose + samp)
as.nm(dose + samp | demo) #as.nm executes once
meds
long <- deranged(meds,start='HOUR',stop='STOP')
long$EVID <- 2
as.nm( dose + samp + long)
data <- as.nm( aug(dose,EVID=1, SEQ=1) + aug(samp,EVID=0, SEQ=0) | demo)
summary(data,by=c('EVID','SEQ'))
## Not run: index(data)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.