Package 'metrumrg' - CiteSeerX

306
Package ‘metrumrg’ February 18, 2014 Type Package Title Pharmacometric tools for data preparation, modeling, simulation,and reporting Version 5.55 Date 2014-02-04 Author Tim Bergsma, Bill Knebel, Leonid Gibiansky, Natalie Hsiang Maintainer Tim Bergsma <[email protected]> Depends reshape, lattice, XML, MASS, methods, grid Suggests chron, fork Description Pharmacometric tools for common data preparation tasks, stratified bootstrap resampling of data sets, NONMEM control stream cre- ation/editing,NONMEM model execution, creation of standard and user-defined diagnos- tic plots,execution and summary of bootstrap and predictive check results, implementation of simulations from posterior parameter distributions, reporting of output tables and creation of detailed analysis logs. License GPL NeedsCompilation no Repository CRAN Date/Publication 2014-02-18 22:22:09 R topics documented: metrumrg-package ..................................... 6 accept ............................................ 7 acceptance .......................................... 8 addl ............................................. 9 align.decimal ........................................ 11 as.best.default ........................................ 12 1

Transcript of Package 'metrumrg' - CiteSeerX

Package ‘metrumrg’February 18, 2014

Type Package

Title Pharmacometric tools for data preparation, modeling, simulation,and reporting

Version 5.55

Date 2014-02-04

Author Tim Bergsma, Bill Knebel, Leonid Gibiansky, Natalie Hsiang

Maintainer Tim Bergsma <[email protected]>

Depends reshape, lattice, XML, MASS, methods, grid

Suggests chron, fork

Description Pharmacometric tools for common data preparation tasks, stratifiedbootstrap resampling of data sets, NONMEM control stream cre-ation/editing,NONMEM model execution, creation of standard and user-defined diagnos-tic plots,execution and summary of bootstrap and predictive check results, implementationof simulations from posterior parameter distributions, reporting of outputtables and creation of detailed analysis logs.

License GPL

NeedsCompilation no

Repository CRAN

Date/Publication 2014-02-18 22:22:09

R topics documented:metrumrg-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6accept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7acceptance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8addl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9align.decimal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11as.best.default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1

2 R topics documented:

as.comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13as.data.frame.block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15as.flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16as.init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17as.keyed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20as.nm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22as.nmctl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25as.pxml.ext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27as.second . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29as.spec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30as.unilog.run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32as.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35AUC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36aug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37backtrans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42bundleRead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43c.timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44cast-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47check.subjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48CLNR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48closers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50colname<- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55compileflag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57compute.cwres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68convertLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69css . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70cv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71dataFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72dataSynthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74deranged . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76diagnosticPlots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78digest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79electronicAppendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81encode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83episcript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

R topics documented: 3

filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86findNonmemCommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87first . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88fixedwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89fixProblem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91ftable2data.frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93getCovs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94getCwres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95getdname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96getPars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97getTabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97glue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98groupnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99half.matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101helpAdminister . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102helpBrowse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103helpClasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103helpDataFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104helpList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104helpMatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122helpModel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122helpPharmacometric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123helpPrepare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123helpQuantify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124helpReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124helpSimulate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125helpStrategic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125helpVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126helpVisualize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126ibw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128inner.data.frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131is.alpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133is.defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134is.diagonal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135is.latex.token . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136is.one.nonalpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137is.square.matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138isSubversioned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139isSubversionedFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140iterations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140justUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142keyed-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144latest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145latex.args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146latex.options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147locf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

4 R topics documented:

lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149ltable.data.frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152matches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153melt.keyed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155metaMerge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157metaSub.character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158metrumrgURL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161monotonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162naInContext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164nasum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165ncomma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166nest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167nix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168nm.pl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168nmPlots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170nmVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171NONR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172omegacor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177Ops.keyed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179ord.matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182packageCheck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183panel.densitystrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184panel.hist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188panel.stratify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190parameter2wiki . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192params . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193parens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194partab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195percent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197plot.nm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198plotfilename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199PLOTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203posmat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204prev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204purge.dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206purge.files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207qstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207qsub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209reapply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210resample.data.frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212rinvchisq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214riwish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215rlog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215row2tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217runCommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

R topics documented: 5

runlog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221runNonmem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223runstate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226safe.call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228safeQuote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228setCwres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230shuffle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231simblock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232simpar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233snap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235sortedInstall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238specfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240sqrtm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241stableMerge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242star . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243strain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245summary.nm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246superset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248supp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250svnIsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252svnMarkAsNonText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253svnMarkAsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254svnMimeType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255svnPropGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256svnPropGetFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257svnPropSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258svnPropSetFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259svnSetMimeType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261tabular.data.frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262tabularformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267tagvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268text2decimal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269timepoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270Tmax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277Tmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278totitle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279tweak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281wikiparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282win . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284wrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285xlog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286xpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

6 metrumrg-package

xyplotExt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

Index 292

metrumrg-package Pharmacometric Tools for Data Preparation, Modeling, Simulation,and Reporting

Description

This package includes pharmacometric tools for common data preparation tasks, stratified bootstrapresampling of data sets, NONMEM control stream creation/editing, NONMEM model execution,creation of standard and user-defined diagnostic plots, execution and summary of bootstrap andpredictive check results, implementation of simulations from posterior parameter distributions, re-porting of output tables, and creation of detailed analysis logs.

Details

I want to ....

• prepare or manipulate data

• model data in NONMEM

• simulate from existing models

• plot model inputs or outputs

• calculate general statistics

• report modeling and simulation results systematically

• administer related files and file systems

• list all functions

• browse extended examples

Package: metrumrgType: PackageVersion: 5.55Date: 2014-02-04License: GPL

Author(s)

Tim Bergsma, Bill Knebel, Leonid Gibiansky, Natalie Hsiang. Maintainer: Tim Bergsma <[email protected]>

References

http://metrumrg.googlecode.com

accept 7

accept Document Acceptance of an R Installation

Description

Execution of accept is a procedural act pertininent to installation qualification. The function logsan act of acceptance of the current installation, noting the conditions of acceptance. Currently,the conditions include the login of the acceptor, the time of acceptance (GMT) and any contingentpackages that survive packageCheck.

Usage

accept(contingencies = c('akima','boot','coda','chron','foreign','fork','lattice','locfit','MASS','nlme','plyr','R2WinBUGS','reshape','SASxport','survival'),installMissing = TRUE,...,lib.loc = .libPaths(),lib = lib.loc[[1]],type = 'source')

Arguments

contingencies a character vector of packages that must survive packageCheck in order foracceptance to succeed. Can be NULL. Defaults are arbitrarily chosen to suit theneeds of Metrum Research Group LLC.

installMissing scalar logical: should install.packages be attempted for missing contingen-cies?

... extra arguments, ignored

8 acceptance

lib.loc character vector of library trees to be searched; passed to installed.packagesand packageCheck

lib character string for library to which any needed packages will be installed;Passed to installed.packages

type passed to install.packages

Details

The file ‘accept.xml’ in .Library is created if it does not exist, and appended if it does. Inaddition to the acceptor’s login and the time, names, versions, and paths of any contingent packagesare stored.

If installMissing is TRUE, the function notes the packages not in lib.loc and tries to install themto lib before trying to load them.

Value

an invisible named vector of version identifiers, where the names are package names.

Note

No accommodation is made for the case where a package is installed in more than one of the loca-tions indicated by lib.loc. Result will be determined by the default behaviors of installed.packagesand library, both of which accept lib.loc and presumably use the first encountered instance ofany package name.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• packageCheck

• acceptance

acceptance List the History of Acceptance.

Description

This function reads ‘accept.xml’ in .Library, if it exists, and prints it with the default method.

addl 9

Usage

acceptance()

Details

Data is displayed as XML markup.

Value

an object of class XMLNode

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• accept

• packageCheck

addl Calculate a NONMEM ADDL data item from explicit records.

Description

The NONMEM data item ADDL on a dose record expresses the number of additional implicit dosesthat should follow at a regular interval II. In the case where explicit doses exist, addl supportscompacting them into ADDL/II notation.

Usage

## Default S3 method:addl(x, interval=1,...)## S3 method for class 'data.frame'addl(x,interval=24,collapse=TRUE,cols=c('SUBJ','TIME','AMT','ADDL','II'),...)

10 addl

Arguments

x numeric

interval numeric, e.g. hours

collapse boolean: drop explicit records that are implied by ADDL

cols conventional column names, as for as.nm

... ignored

Details

For the default method, if an element of x is followed by n elements that occur at a fixed intervalinterval, n is returned at that position and NA is returned for each of the following elements. nmay be zero.

It is the responsibility of the user to apply the function to meaningful subsets of the data, if any:e.g., sequential records with common subject and dose.

For the data.frame method, an attempt is made to apply the default method, making assumptionsabout the structure of the data set. An error results if non-zero ADDL is calculated where ADDLis already non-zero. If collapse is TRUE, superfluous records are dropped; otherwise, their row-names are prefixed with "-".

Value

a numeric vector as long as x

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• reapply

Examples

test <- data.frame(SUBJ=c(1,1,1,1,1,2,2,2,2,2),TIME=c(1,2,3,4,5,1,2,3,4,5),EVID=c(1,1,1,1,0,1,1,1,1,0),AMT =c(1,1,1,1,0,1,1,1,2,0),DV =c(0,0,0,0,1,0,0,0,0,1))testaddl(test,interval=1)addl(test,interval=1,collapse=FALSE)

align.decimal 11

align.decimal Format Numeric Vectors Specially

Description

Format a numeric vector so that decimal mark is a constant distance from the end or beginning ofeach element.

Usage

align.decimal(x, decimal.mark = ".", ...)padded(x,width = 4,...)

Arguments

x numericdecimal.mark character indicating decimalwidth numeric indicating total digits... ignored

Details

for align.decimal, each element is formatted separately using prettyNum, then the characterresults are padded with spaces on the right, so that the decimals align. Whole numbers without thedecimal mark get an extra space in its place.

For padded, x (numeric) is formatted with zero decimal places, no decimal, and enough leadingzeros to ensure width width.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• tabular.data.frame

Examples

align.decimal(c(.12, 1.2, 12.0))padded(c(1,10,100,1000),5)

12 as.best.default

as.best.default Coerce data unambiguously to numeric or character

Description

In some sense, numeric and character are the most general data types. as.best converts to one ofthese, handling missing or near-missing values systematically.

Usage

## Default S3 method:as.best(x,prefix='#',na.strings=c('.','NA',''),...)

## S3 method for class 'data.frame'as.best(x,...)

Arguments

x object to be coercedprefix scalar character value to affix to numeric-like values in a vector containing non-

numeric valuesna.strings character vector of values to treat as NA... ignored

Details

Data printed at the command prompt can contain many ambiguities. Factors look just like charactervectors. Empty strings look just like spaces. Leading or trailing white space can be confused withalignment adjustments. The string value ’NA’ can be confused with NA. Character ’TRUE’ lookslike logical TRUE.

as.best.default coerces its argument to character, strips leading and trailing white space, andcoerces na.strings to NA. A numeric vector is returned if all non-missing values can be coercedto numeric. A character vector is returned if any non-missing values cannot be coerced to numeric.If a prefix is supplied (the default) numbers in a mixed vector are prefixed thus; if prefix is lengthzero, mixed character-numeric gives an error.

The method for data.frame coerces each column in turn, returning either the updated data frameor an error indicating the first problematic column.

Value

an object like x

Author(s)

Tim Bergsma

as.comment 13

References

http://metrumrg.googlecode.com

See Also

• as.character

• as.numeric

• as.mDate

• as.comment

Examples

as.best(head(Theoph))

as.comment Create and Manipulate Comment Objects

Description

Some conventions include the use of ‘C’ or ‘.’ as the first element in a row. ‘C’ is typically usedto identify a row to be ignored “commented-out”. Here, a comment is really a logical that shouldnever be NA, and prints as ‘C’ or ‘.’ (TRUE,FALSE).

Usage

## S3 method for class 'comment'x[..., drop = TRUE]## S3 method for class 'comment'x[[..., drop = TRUE]]## Default S3 method:as.comment(x, ...)## S3 method for class 'comment'as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'comment'as.character(x, ...)## S3 method for class 'comment'as.comment(x, ...)## S3 method for class 'comment'c(..., recursive = FALSE)## S3 method for class 'comment'format(x, ...)## S3 method for class 'data.frame'hide(x, where, why, ...)## S3 method for class 'comment'print(x, ...)## S3 method for class 'comment'

14 as.comment

rep(x, ...)## S3 method for class 'data.frame'hidden(x, ...)## S3 method for class 'comment'unique(x,incomparables=FALSE,...)## S3 method for class 'comment'xtfrm(x)## S3 method for class 'hidden.data.frame'summary(object, ...)

Arguments

x the comment object, or something coercible to logical (data.frame for hidden.data.frame)

... extra arguments, generally ignored

drop coerce to lowest possible dimension

row.names row names for the result

optional Optional to use the object name as the column name?

recursive unused, present for historical reasons

where logical with length nrow(x), indicating rows to hide

why a column name suggesting the reason for hiding

object hidden.data.frame

incomparables see unique

Details

Objects of class comment can be used exactly like logicals, but look like conventional comments.hide.data.frame implements consistent commenting of rows, including a reason for the comment.hidden and summary methods analyze the result. hidden.data.frame returns just the hidden rows,classified as ‘hidden.data.frame’. summary.hidden.data.frame indicates, for each flag, the num-ber of records commented for that reason (total) and the number of records commented for onlythat reason (unique), if any. If hidden(x) has no hide flags, the result is a data frame with one cell:ncol=0. If hidden(x) has no rows, the result is a data frame with one cell: nrow=0.

Value

comment, or data.frame for hide.data.frame, etc.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

as.data.frame.block 15

Examples

Theoph <- hide(Theoph, where=Theoph$conc < 1,why='blq')Theoph <- hide(Theoph, where=Theoph$Subject==1,why='suspect')hidden(Theoph)summary(hidden(Theoph))

as.data.frame.block Convert a Block of Lines to Data Frame

Description

A block is a character vector where each element represents a line of text from a table. This functionconverts the character vector to a data.frame. The first line must be a header, and names will not bechecked.

Usage

## S3 method for class 'block'as.data.frame(x, ...)

Arguments

x character

... extra arguments passed to read.table

Details

The function calls read.table with header=TRUE, as.is=TRUE, and check.names=FALSE. It is anerror to specify these arguments.

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• read.table

16 as.flag

Examples

as.data.frame.block(c('just an example','run param estimate','1 CL 45','1 V2 70','1 Ka 3.14'))

as.flag Create and Manipulate Flags

Description

A flag is is an integer that may be imputed as zero where missing. These functions implement theclass. Other functions may do the imputation as necessary.

Usage

## S3 method for class 'flag'x[..., drop = TRUE]## S3 method for class 'flag'x[[..., drop = TRUE]]f(x, ...)## S3 method for class 'flag'as.character(x, ...)## S3 method for class 'flag'as.data.frame(x, row.names = NULL, optional = FALSE, ...)## Default S3 method:as.flag(x, ...)## S3 method for class 'flag'as.flag(x, ...)## S3 method for class 'flag'c(..., recursive = FALSE)## S3 method for class 'flag'format(x, ...)## S3 method for class 'flag'print(x, ...)## S3 method for class 'flag'rep(x, ...)## S3 method for class 'flag'xtfrm(x)

as.init 17

Arguments

x the flag object, or something coercible to integer

... extra arguments, ususally ignored

drop coerce to lowest possible dimension

row.names row names for the result

optional Optional to use the object name as the column name?

recursive unused, present for historical reasons

Details

Typically a flag takes on the values of zero and 1, and is used to indicate the presence of a particularcondition. Other functions are welcome to impute NAs as 0. Methods are defined for commonclasses. f is an alias to as.flag.

Value

flag

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

hide(Theoph,where=Theoph$conc < 1,why='BLQ')

as.init Work with Initial Estimates as Objects

Description

as.nmctl and read.nmctl normally return a list of character vectors as class nmctl. Users arefree to modify these using conventional techniques for text. Optionally, the theta record can beconverted to an object of class initList – either manually, using as.initList, or by the functionsabove, passing parse=TRUE. initList is a numbered list of objects of class init, each of whichcan be modified using regular R syntax for lists and vectors. Conveniently, the object number is thesame as NONMEM’s index for THETA: e.g. ctl$theta[[3]] represents THETA3.

18 as.init

Usage

## S3 method for class 'numeric'as.init(x = numeric(0), fixed = FALSE, comment = character(0), ...)## S3 method for class 'character'as.initList(x, ...)## S3 method for class 'numeric'as.initList(x, fixed = FALSE, comment = character(0), ...)

Arguments

x object of interest

fixed logical: whether the value should be fixed at the initial estimate.

comment character: a comment

... ignored

Details

Class init represents an initial estimate, e.g. for an element of THETA. Using the NONMEMhelp conventions, the estimate is composed of three elements: a lower bound, the estimate it-self, and an upper bound; these are named "low", "init", and "up", respectively. They are alwayspresent, whether or not displayed. Each may have a numeric value. Furthermore, "low" may be-Inf (default), "init" may be NA (if "low" and "up" are finite) and "up" may be Inf (default).init may be constructed from numeric vector of length one (’init’), two (’low’ and ’init’) or three(’low’,’init’,’up’).

Elements of class init may be accessed using subset operators ([], or either version of the element-select operator ([[]],$); assignment is supported for all three cases. Note that a subset of class initis not itself of that class.

In contrast, a subset of class initList retains its class. initList is a list of objects of class init.Members may be accessed and assigned using [] and [[]]. initList may be created by parsing afile or by calling as.initList on a character or numeric vector.

The concept "fixed" is supported. fixed() checks whether an init is fixed, either singly ormember-wise for elements of initList. fixed() <- assigns the value TRUE or FALSE; for initList,the supplied value is recycled as necessary to match the length of the primary object. Internally,"fixed" simply means that "low", "init", and "up" are finite and identical.

Comments are supported. Comments can be multi-line, and will be printed following a line repre-senting the initial estimate itself. When parsing, comments on the same line as – or following a setof – estimates are replicated for all such estimates (perhaps only one). If an estimate is split acrosslines, comments for each of those lines are aggregated and associated with the estimate as a whole(and are printed after the estimate). Comments occuring before the first line of numeric materialwill be associated with the list as a whole, and will be printed before the list. Comments may beaccessed using comment() and assigned using comment() <- .

Value

object of class init, or a numbered set of these, having class initList.

as.init 19

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.nmctl

Examples

path <- system.file('example/project/nonmem/ctl/1005.ctl',package='metrumrg')ctl <- read.nmctl(path,parse=TRUE)theta <- ctl$thetatheta[[3]]$initx <- as.initList('(0,3) 2 FIXED (0 .6 1) 10 (-INF,-2.7,0) (37 FIXED) ')xfixed(x)fixed(x) <- TRUExwriteLines(as.character(x))fixed(x) <- FALSExx[[1]]as.init(1:3)as.initList(1:3)as.initList(1:3,fixed=TRUE)x <- as.initList(1:4)xx[1:3]x[1:2] <- x[3:4]xx[[4]]fixed(x[[4]])fixed(x[[4]]) <- TRUExx[[4]]$upx[[4]]$up <- Infx[[4]]fixed(x[[4]])x[[4]][['up']]x[[4]][c('low','up')]x <- c(

';thetas','10 20; structural','; literature','(','0,;ref A','5,;ref B','10)'

20 as.keyed

)writeLines(as.character(as.initList(x)))

as.keyed Create and Manipulate Keyed Data Frames

Description

The class keyed is a subclass of data.frame with a key attribute. The key is a vector of columnnames which, taken together, should provide enough information to uniquely distinguish each row.Specific functions and methods take advantage of this information.

Usage

## S3 method for class 'keyed'x[i, j, drop]

## S3 method for class 'keyed'aggregate(x, by=x[,setdiff(key(x),across),drop=FALSE], FUN, across=character(0), ...)## S3 method for class 'data.frame'as.keyed(x, key=character(0), ...)dupKeys(x, ...)key(x, ...)key(x) <- value## S3 method for class 'keyed'merge(x, y, ...)naKeys(x, ...)unsorted(x, ...)## S3 method for class 'keyed.summary'print(x, ...)## S3 method for class 'keyed'sort(x, decreasing = FALSE, ...)## S3 method for class 'keyed'summary(object, ...)## S3 method for class 'keyed'transform(`_data`, ...)## S3 method for class 'keyed'uniKey(x,key=NULL,...)

Arguments

x a (keyed) data.frame

i first index

j second index

drop whether to drop unused dimensions

by a list of indices as long as nrow(x), whose interaction gives the aggregates(groups)

as.keyed 21

FUN an aggregating function

across column names in key(x) across which to aggregate; see details

... extra arguments, usually ignored, but passed to FUN in aggregate

key a character vector of column names in x that should uniquely distinguish eachrow

value a key (character vector of column names)

y the right argument in the merge

decreasing (coercible to) logical; length 1

object a keyed data.frame

_data a keyed data.frame

Details

The generic as.keyed is the usual way of creating a keyed object. The method as.keyed.data.framecalls key<-. The function key allows checking an object’s key. A data.frame can be re-keyed by asubsequent call. Generally, a data.frame should be keyed on columns that actually exist, but this isnot enforced. as.data.frame.keyed removes the key and reverts the class.

In aggregate.keyed, the default behavior is to aggregate by the key columns, i.e., to eliminateduplicate keys by aggregation. by can be specified arbitrarily, but must be a named list (e.g., adata.frame) with each element as long as nrow(x). Each element in by will displace any like-named element in x, and names(by) will serve as the key of the result. If by has length zero, (as itdoes by default when across is key(x)) the entire data set is aggregated into a one row data.frame.

across is a convenience argument to aggregate.keyed. If specified, it must be a subset of (or allof) key(x). Columns indicated by across are dropped from x and from the default by value, andaggregation proceeds irrespective of those columns.

The function naKeys detects rows for which one or more key fields is NA.

The function dupKeys detects all rows for which there is another row (earlier or later) with identicalkey. That means it can never identify a single row, as duplicated can: it identifies the duplicatesas well as those rows of which they are duplicates. It is recommended to test for NAs before testingfor duplicates.

The keyed method for unsorted detects rows that would move on sort.

Methods for merge and transform are key-friendly. The method for summary is key-centric.

uniKey creates a character vector (class uniKey) by pasting the key columns with \r. (Keys con-taining \r are unsupported.) The as.character method substitutes a space character for \r.

Value

Most functions and methods documented here return objects with class c(’keyed’,’data.frame’).

key<- and methods for summary and print are used for side effects.

uniKey.keyed returns a character vector as long as nrow(x), class uniKey.

naKeys, dupKeys, and unsorted return logical vectors as long as nrow(x).

22 as.nm

Note

Values in key columns should not contain \r, which is used as a delimiter in dupKeys and uniKey.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• Ops.keyed

• melt.keyed

• cast,keyed-method

Examples

a <- sort(as.keyed(Theoph,key=c('Subject','Time')))summary(a)aggregate(a, across='Time',FUN=mean)

as.nm Create and Manipulate nm Objects

Description

Objects of class nm are intended to support analysis using the software NONMEM ((c), Icon De-velopment 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 nmobject from an existing object. The read and write methods are wrappers for ‘.csv’ equivalents.read.nm reconstitutes classes for flags, DATETIME, and C.

Usage

nm()## S3 method for class 'data.frame'as.nm(x, ...)read.nm(x,na.strings='.',as.is=TRUE,key=c('SUBJ','TIME','SEQ'),flags=character(0),...)write.nm(x, file, na = '.', row.names = FALSE, quote = FALSE, ...)

as.nm 23

Arguments

x data.frame or nm

na.strings passed to read.csv

as.is passed to read.csv

key passed to as.keyed

flags character vector naming colums to convert using as.flag

... extra arguments, ignored or passed to write.csv

file passed to write.csv

na passed to write.csv

row.names passed to write.csv

quote passed to write.csv

Details

as.nm.data.frame is the principal method that creates an nm classification. It alone enforces allqualities of class nm. read.nm is the only other function that creates an nm classification; use withcaution, 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 meth-ods may make use of the passed argument data, which contains the data set itself. Any enforced orconditional outputs (see column summary) have the column name as the first member of the classvector.

• SUBJ must be present and defined, even for commented records. ID is (re)calculated asas.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 matchingTIME.

• 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-commenteddose), and LDOS (amount of most recent non-commented dose) will be calculated if AMT ispresent. 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 concep-tually relevant, given study design. If two doses are given at the same time, say in differentcompartments, LDOS reflects the first AMT with respect to sort order.

24 as.nm

• 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, ifpresent.

• 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

Value

write.nm is used for side effects. Others return an object with class c(’nm’,’keyed’,’data.frame’).

Note

Assembly chains, such as nm() + dose + samp | demo, are no longer supported. as.moot andas.rigged are deprecated.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• summary.nm

• Ops.keyed

Examples

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

as.nmctl 25

)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() + doseas.nm(dose)as.nm(dose + samp)as.nm(dose + samp | demo) #as.nm executes once#nm() + dose + samp | demo #deprecated

medslong <- deranged(meds,start='HOUR',stop='STOP')long$EVID <- 2as.nm( dose + samp + long)#nm() + dose + samp + long - as.moot() # deprecated#nm() + dose + samp + as.rigged(n=10) # deprecateddata <- 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)

as.nmctl Create, Manipulate, Read, and Write NONMEM Control Streams

Description

This family of functions implements the class nmctl: an object model of the NONMEM controlstream. nmctl models a control stream as a list of records; each record is a character vector. Theread and write functions (not generic) convert nmctl to and from file format. The print, format, andas.character methods display nmctl as it normally looks in a text editor. as.list.nmctl simplyunclasses its argument. as.nmctl.character does the heavy work, breaking up a character vectorinto records and storing as a list. If parse is TRUE, as.nmctl attempts to convert certain records tohigher-level objects: currently the theta record will be converted to initList .

26 as.nmctl

Usage

## S3 method for class 'nmctl'as.character(x, ...)## S3 method for class 'nmctl'as.list(x, ...)## S3 method for class 'character'as.nmctl(x,pattern='^ *\$([^ ]+)( .*)?$',head='\\1',tail='\\2',parse=FALSE,...)## S3 method for class 'nmctl'format(x, ...)## S3 method for class 'nmctl'print(x, ...)read.nmctl(con,parse=FALSE, ...)write.nmctl(x,file = "data",ncolumns = 1,append = FALSE,sep = " ",...)## S3 method for class 'nmctl'x[..., drop = TRUE]## S3 method for class 'nmctl'x[[..., drop = TRUE]]

Arguments

x an nmctl object (or analogous character vector)... extra arguments passed to other functionspattern regular expression for first line of a control recordhead regular expression (relative to pattern) giving the name of the control recordtail regular expression (relative to pattern) giving the balance of the control recordcon a connection or the name of a file to openparse whether to create R objects from the character vectors serving as recordsfile passed to write

ncolumns passed to write

append passed to write

sep passed to write

drop coerce to lowest possible dimension

as.pxml.ext 27

Details

Serendipitously, the record indicator in NONMEM control stream syntax is the same as the elementselector in R list syntax: $. The convention is that names of elements in nmctl (lower case) are con-verted to record types (upper case) in the control stream. The user is free to add, delete, rearrange,and edit records using standard list manipulation techniques. When printed, records appear in listorder. The write function warns if the 80 character limit is exceeded (not including comments).

Valueas.character.nmctl

a character vector representing a control stream

as.list a list representing a control streamas.nmctl.character

a control stream object

format.nmctl character

print.nmctl character

read.nmctl a control stream object

write.nmctl used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.initList

• write

as.pxml.ext Convert a Param File to XML

Description

Convert the contents of a file to XML, encoding the leading lines as a ‘note’ element and thefollowing lines as a table.

Usage

as.pxml.ext(file, lead = 1, tag = 'param', ...)

28 as.pxml.ext

Arguments

file path to a parameter file

lead number of leading ‘note’ lines

tag name for the enclosing element

... ignored

Details

The ‘note’ and ‘body’ are identified, and coerced using as.xml. The result is nested in an elementwith the name specified by tag. The first column of ‘body’ is used as the key.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.xml

• xyplotExt

Examples

ext <- c('TABLE NO. 1: First Order: Goal Function=MINIMUM VALUE OF OBJECTIVE FUNCTION',' ITERATION THETA1 THETA2 THETA3 SIGMA(1,1) OMEGA(1,1) OBJ',' 0 1.70000E+00 1.02000E-01 2.90000E+01 0.00000E+00 1.17001E+00 11.57008663984839',' 2 1.78158E+00 1.06239E-01 3.05314E+01 0.00000E+00 1.08862E+00 9.377909428896904',' 4 1.91182E+00 1.05179E-01 3.14289E+01 0.00000E+00 8.96680E-01 8.983605357031118',' 6 1.94836E+00 1.01426E-01 3.20728E+01 0.00000E+00 9.06374E-01 8.940731060922468',' 8 1.93983E+00 1.01742E-01 3.20128E+01 0.00000E+00 8.99988E-01 8.940110966224346',' 10 1.94057E+00 1.01681E-01 3.20217E+01 0.00000E+00 8.99322E-01 8.940101673144566',' 11 1.94057E+00 1.01681E-01 3.20217E+01 0.00000E+00 8.99322E-01 8.940101673144566',' -1000000000 1.94057E+00 1.01681E-01 3.20217E+01 0.00000E+00 8.99322E-01 8.940101673144566',' -1000000001 6.28499E-01 7.36368E-03 1.25313E+00 0.00000E+00 5.44628E-01 0.')file <- textConnection(ext)pxml <- as.pxml.ext(file)close(file)pxml

as.second 29

as.second Interconvert Nominal Time Units

Description

Perform standard conversions among various common time units.

Usage

as.second(x, ...)as.minute(x, ...)as.hour(x, ...)as.day(x, ...)as.week(x, ...)as.month(x, ...)as.year(x, ...)

Arguments

x numeric... ignored

Details

The functions listed above are generic. Methods exist, either explictly or implicitly, for objectsclassified to represent second, minute, hour, day, week, month, and year. All these objects aresubclasses of "duration"; as.<n>.duration serves wherever explicit methods are omitted. Foreach generic, methods exist for class "numeric". For each class, methods exist for the generics"format" and "print".

The strategy for time unit conversion is to classify a numeric vector according to some unit, andthen coerce that object to some other class. Thus, as.day(7) is not particularly interesting, butas.week(as.day(7)) yields 1.

Conversions use 60 seconds per minute, 60 minutes per hour, 24 hours per day, 7 days per week,28 days per month, and 365.25 days per year. Currently, no other relationships are specified. Notethat 12 nominal months does not make a full year. This is experimental, and may change in futureversions.

The duration classes are also subclasses of timeline, which exists to support addition and sub-traction of durations and timepoints. See examples here, and at timeline. You cannot add twotimepoints, nor can you subtract a timepoint from a non-timepoint. When one argument is a time-point, the other is coerced using as.second, and the result is the timepoint class. For two durations,the second value is coerced to the class of the first, with a message, if necessary. Otherwise, if onlyone argument is a duration, the other is coerced to that class. Negative durations are allowed.

Value

an S3 "num" object with class c(n, ’duration’,’timeline’,’numeric’), where ‘n’ is "second","minute", "hour", "day", "week", "month", or "year", as implied.

30 as.spec

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.mDateTime

• timeline

• c.timeline

Examples

as.year(as.month(12))as.year(as.day(365.25))as.second(as.year(1))as.month(2) + as.week(2)as.week(2) + as.month(1)as.month(2) - as.week(2)as.week(2) - as.month(1)as.week(2) + 1as.week(2) - 12 + as.week(1)2 - as.week(1)class(c(as.day(1),as.day(2)))class(as.day(1:5)[3])class(as.day(1:5)[[3]])class(seq(from=as.day(2),to=as.day(6)))class(rep(as.day(1),5))

as.spec Create and Manipulate spec Objects

Description

A spec is a keyed data.frame giving an abstract specification of a data table. It has columnscolumn, label, type, guide, required,and derivation. These are descriptive or pre-scriptive for the specified table. The character method for as.spec expects a scalar file name.as.vector returns the documented column names. read.spec and write.spec use unquoted,tab-delimited cells, with ‘’, ‘.’, and ‘NA’ representing missing values (na strings). The summarymethod does not worry about sort order. Generally one should not sort a spec, since record order isinformative.

as.spec 31

Usage

## S3 method for class 'character'as.spec(x, ...)## S3 method for class 'data.frame'as.spec(x, ...)## S3 method for class 'spec'as.vector(x, mode = "any", ...)## S3 method for class 'spec'summary(object, ...)read.spec(x, ...)write.spec(x, file, ...)

Arguments

x object of dispatch

object object of dispatch

mode passed to as.vector

file character

... ignored or passed

Details

column gives the name and order of columns.

label is a descriptive substitute for column.

type is one of character,numeric, integer, or datetime, where datetime indicates some-thing in the timepoint class.

guide is interpretive material: typically units for numeric columns, or encoded levels for factor-likecolumns. datetime columns expect a corresponding format string, as for as.mDateTime. Numericguides are formally composed of an optional descriptor called guidetext followed by an optionalrange specifier in the form [0,30] or (0,30], etc.

required is an enforceable presence specifier, typically 0 or 1. It can be any R expression that canbe coerced to logical and evaluated in the environment defined by the specified data frame.

derivation is (non-tab) free text intended as a high-level description of how the column dependson other columns or data sources.

Value

object of class spec keyed data.frame for read.spec and as.spec

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

32 as.unilog.run

See Also

• specfile

• specification

• codes

• encode

• %matches%

Examples

example(`%matches%`)

as.unilog.run Create a Run Log for NONMEM7 using NONMEM6 Format

Description

metrumrg includes an INFN routine for NONMEM6 and earlier that creates a comma-separatedlisting of parameter estimates and their percent relative standard errors. This function emulates thatdata, using the ‘.ext’ file produced under NONMEM7. as.runlog.unilog converts the outputto the format used for NONMEM6. The default for tool changed from ’nm6’ to ’nm7’ at version5.18.

Usage

as.unilog.run(run,logfile='NonmemRunLog.csv',outfile=paste(run,'lst',sep='.'),extfile=file.path(dirname(outfile),paste(run,'ext',sep='.')),tool='nm7',...)

Arguments

run name of the NONMEM run, typically integer

logfile path for the NONMEM run log file

outfile path for the NONMEM output file, typically ‘run.lst’

extfile path for the NONMEM estimates, by default ‘run.ext’

tool currently ‘nm7’

... passed to other functions

as.xml 33

Details

The ‘ext’ file is digested. In particular the rows labeled -1000000000 and -1000000001 are taken asthe parameter estimates and standard errors, respectively. The minimization status (min) is either 0(minimized) or 1 for NONMEM7, which is less informative than for NONMEM6. The covariancestatus (cov) is normally 0. It will be 1 if covariance was requested but no standard errors appear inextfile (as for NONMEM6).

Value

data.frame with columns tool, run, parameter, moment, value.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.unilog.lst

• as.unilog.pxml

• as.runlog.unilog

as.xml Represent an Object as XML

Description

as.xml is generic, with a default method and methods for character and data.frame. The intent is toconvert text-like objects to informal XML that can be navigated with XPath expressions, e.g. usingpackage XML.

Usage

## Default S3 method:as.xml(x, tag, ...)## S3 method for class 'character'as.xml(x, tag, ...)## S3 method for class 'data.frame'as.xml(x,keyname='row',key=rownames(x),...)

34 as.xml

Arguments

x an object to convert

tag an XML element name for open and close tags in which to enclose members ofx; can be a vector

keyname an XML element name to hold each value of each column in x

key a vector of unique identifiers to distinguish each value of each column in x

... name/value pairs to construct attributes in the ‘open’ tags (ignored for the data.framemethod)

Details

The default method simply coerces its argument to character.

The character method pastes tag as an XML element name (in brackets) before and after x. Dotsare used to construct attributes. Like tag itself, the attributes can be vectors; in both cases the usualrecycling rules apply, as for paste.

The data.frame method calls the character method on each of its columns, passing keyname andkeys as tag and key, respectively. keys should generally be unique. Note that the columns haveno parent: supply one manually with nest, if necessary.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.pxml.ext

Examples

nest(as.xml(head(Theoph)),tag='frame')

attribute 35

attribute Encode an Attribute for an XML Open Tag

Description

Encode an attribute for an XML open tag, in the form tag=’x’.

Usage

attribute(x, tag, ...)

Arguments

x character vector: attribute value(s)

tag character (vector): attribute name

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• bracket

Examples

attribute(letters,'letter')

36 AUC

AUC Calculate AUC Using the Trapezoidal Method

Description

Calculate the area under the curve (AUC) for each subject over the time interval for dv using thetrapezoidal rule.

Usage

AUC(data, time = 'TIME', id = 'ID', dv = 'DV')

Arguments

data data.frame containing the data to use for the AUC calculation

time chronologically ordered time variable present in data

id variable in data defining subject level data

dv dependent variable used to calculate AUC present in data

Details

The AUC function performs the calculation based on the variables id, time, and dv present in the Rdata object. Warnings are issued if any of these contain NA.

Value

One area under the dv-time curve is returned for each subject.

Author(s)

Leonid Gibiansky

References

http://metrumrg.googlecode.com

aug 37

aug Augment a List-like Object

Description

Add named elements to an object.

Usage

aug(`_data`, ...)

Arguments

_data a list-like object

... name-value pairs

Details

For each extra argument, an attempt is made to assign its value to a like-named element of x (typ-ically a list or data.frame). The augmented object is returned. Similar to transform, but simpler.Each argument will be evaluated first in an environment constructed from _data.

Value

like _data

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• transform

Examples

head(aug(Theoph,study='b'))

38 bin

backtrans Back-transform Columns in a Data Frame

Description

Exponentiate presumably log-transformed columns in a data.frame.

Usage

backtrans(x, cols)

Arguments

x data.frame

cols vector of column names

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

bin Calculate Bin Sizes and Limits for a Vector

Description

Given a numeric vector, calculate bin limits, place each value in a bin, and return the number ofvalues in each bin.

bin 39

Usage

bin(x,population=x,breaks=quantile(population,probs=probs,...),probs=c(0,0.25,0.5,0.75,1),include.lowest=TRUE,...)

Arguments

x a vector of numeric values, to be placed in bins

population a vector of numeric values serving as the reference population for constructingbins

breaks bin limits (boundaries) to pass to cut

include.lowest limit qualifier to pass to cut

probs default probabilities for calculating breaks

... other arguments to pass to quantile and cut

Details

By default, the population used to calculate bin limits is the same as the group of values beingbinned. By default, inner bin limits are the quartiles of the population.

Value

A table with bin limits encoded as column names.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• quantile

• table

• cut

40 bounds

Examples

bin(1:100)bin(1:50,population=1:100)plot(

bin(rnorm(1000),

breaks=seq(from=-3,to=3,by=0.5)

))

bounds Calculate Normal Quantiles at Boundaries of Probability Intervals

Description

qnorm expects scalar means and standard deviations, but a vector of probablities. In contrast, lowerand upper are wrappers for qnorm that accept equal-length vectors for mean and standard devia-tion, but scalar probabilities. Probability can be supplied directly or calculated as the bound of asymmetric interval. bounds pairs lower and upper using suitable notation.

Usage

lower(x, sd, interval = 0.95, prob = 0.5 * (1 - interval), ...)upper(x, sd, interval = 0.95, prob = 0.5 * (1 + interval), ...)bounds(x,sd,interval = 0.95,lower = 0.5 * (1 - interval),upper = 0.5 * (1 + interval),left = "(",right = ")",sep = ",",digits = 3,...)

Arguments

x means

sd standard deviations, of same length as x

prob probability, defaulting to the bounds of a symmetric interval

interval width of a probability interval: e.g. confidence interval

bracket 41

lower probability for the lower bound

upper probability for the upper bound

left character(s) to delimit the lower bound

right character(s) to delimit the upper bound

sep characters to delimit lower and upper quantiles

digits number of significant digits: passed to signif

... other arguments, passed to qnorm

Details

interval is a convenient way to set upper and lower probabilities, and is ignored if these arespecified directly. left and right are passed to paste, and so will be repeated as necessary tomatch the length of x.

Value

lower and upper return numeric. bounds returns character.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• qnorm

Examples

bounds(c(0,0,0),sd=c(.5,1,2))

bracket Create an XML Tag

Description

Create an open or close XML tag of the form <x> or </x>.

Usage

bracket(x, close = FALSE, ...)

42 breaks

Arguments

x an element name

close whether the tag is a close tag; FALSE by default

... name-value pairs of attributes for an open tag

Details

close can be a vector. An attempt will be made to supress attributes for ‘close’ tags.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• attribute

• as.xml.character

Examples

bracket(rep('name',2),close=FALSE:TRUE,row=1,col=2)

breaks Identify Boundaries Between Sets of Elements

Description

Identify boundaries between sets elements.

Usage

breaks(x, ...)

Arguments

x vector

... ignored

bundleRead 43

Details

A vector of length n has at most n-1 divisions between elements. If the elements are taken in runsof repeated elements, a set of divisions <= n-1 may be identified. This function returns a zero foreach between-element position if the bounding elements are identical, and a one for each between-element position if the bounding elements differ. Used for placing lines between sets of rows orcolumns in a table.

Value

integer

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• tabular.data.frame

Examples

breaks(c(1,1,1,2,2,2,3,3,3))

bundleRead Read Data Files from a Directory into a List

Description

bundleRead Reads all files of specified extensions from a directory into a list.

Usage

bundleRead(dir, ext, func, ...)

Arguments

dir character vector or list of directories from which to read files

ext character vector of file extensions to seek

func list of length ext of "read" functions to use on the corresponding file extensions

... optional arguments to func

44 c.timeline

Value

list (usually, of data frames)

Author(s)

Natalie Hsiang

References

http://metrumrg.googlecode.com

See Also

• lapply

c.timeline Support for timepoint Classes

Description

These functions support classes timepoint, timeline, mTime, mDate, and mDateTime (and relatedfunctions). They are mostly S3 methods for base R generics.

Usage

## S3 method for class 'timeline'c(..., recursive = FALSE)## S3 method for class 'timeline'x[..., drop = TRUE]## S3 replacement method for class 'timepoint'x[...] <- value## S3 method for class 'timeline'x[[..., drop = TRUE]]## S3 method for class 'timepoint'as.character(x, ...)as.chartime(x, ...)## S3 method for class 'numeric'as.chartime(x, format, mark=TRUE,...)## S3 method for class 'chartime'as.numeric(x, format,...)## S3 method for class 'timepoint'print(x, ...)## S3 method for class 'timeline'rep(x, ...)## S3 method for class 'timeline'seq(from, to, by, length.out, along.with, ...)

c.timeline 45

Arguments

... arguments to c, or passed to other functions

recursive same meaning as for c

x object of class timepoint

drop same meaning as for ‘[’ and ‘[[’

value value to be assigned, as for ‘[<-’

format input or output format describing character time (see strftime)

mark boolean: mark times with dangling seconds using ‘+’

from as for seq.default

to as for seq.default

by as for seq.default

length.out as for seq.default

along.with as for seq.default

Details

Normally you shouldn’t need to worry about these functions. c and the ‘[’ variants exist just sothat class information is not lost on invocation of the generic. as.character.timepoint andprint.timepoint just call format. chartime variants are used internally by other functions.seq.timeline requires from. If an interval cannot be calculated from supplied arguments, byis set to 1 hour for mTime or 1 day for mDate or mDateTime.

Value

print an invisible object with same class as x

as.chartime generic: does not returnas.chartime.numeric

character (time)as.numeric.chartime

numeric (seconds)as.character.timepoint

character (time)

others object with same class as x

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

46 c.timeline

See Also

• timepoint

• seq.default

• strftime

Examples

#as.data.framedata.frame(dt=as.mDateTime(seq(from=0,by=86500,length.out=3)),d=as.mDate(seq(from=0,by=86400,length.out=3)),t=as.mTime(c(60,120,180)))# dt d t# 1 1970-01-01 00:00 1970-01-01 00:01# 2 1970-01-02 00:01+ 1970-01-02 00:02# 3 1970-01-03 00:03+ 1970-01-03 00:03

#combinec(as.mTime(0),as.mTime(60))# 00:00 00:01c(as.mDate(0),as.mDate(86400))# 1970-01-01 1970-01-02c(as.mDateTime(0),as.mDateTime(86500))# 1970-01-01 00:00 1970-01-02 00:01+

#subsetas.mTime(c('08:00','09:00'))[2]# 09:00as.mDate(c('2008-01-01','2008-01-04'))[2]# 2008-01-04as.mDateTime(c('2008-01-01 12:00','2008-01-04 12:30'))[2]# 2008-01-04 12:30

#element selectionas.mTime(c('08:00','09:00'))[[2]]# 09:00as.mDate(c('2008-01-01','2008-01-04'))[[2]]# 2008-01-04as.mDateTime(c('2008-01-01 12:00','2008-01-04 12:30'))[[2]]# 2008-01-04 12:30

#assignmenta <- as.mTime(seq(60,300, by=60))a#00:01 00:02 00:03 00:04 00:05a[5] <- 60a#00:01 00:02 00:03 00:04 00:01a[3] <- NAa#00:01 00:02 <NA> 00:04 00:01

cast-methods 47

#identityas.mTime(as.mTime(0))# 00:00as.mDate(as.mDate(0))# 1970-01-01as.mDateTime(as.mDateTime(0))# 1970-01-01 00:00

#repetitionrep(as.mTime(86340),2)# 23:59 23:59

#sequenceseq(from=as.mTime('00:00'),length.out=3)seq(from=as.mTime('00:00'),by=as.mTime('00:05'),length.out=3)seq(from=as.mTime('00:00'),by=as.mTime('00:05'),along.with=integer(3))seq(from=as.mTime('00:00'),to=as.mTime('06:00'))seq(from=as.mTime('00:00'),to=as.mTime('06:00'),by=as.mTime('02:00'))seq(from=as.mTime('00:00'),to=as.mTime('06:00'),length.out=4)

cast-methods Methods for Function cast in Package reshape

Description

Methods for function cast in package reshape. metrumrg converts reshape::cast to the defaultmethod for an S4 generic; it also promotes its own S3 class keyed to an S4 class, and defines a castmethod for it.

Methods

signature(data = "ANY") For most purposes, a call to cast will dispatch reshape::cast, thuspreserving existing behavior. See cast.

signature(data = "keyed") The method for keyed mostly declares the same arguments as forcast. The default for fill, however, is changed to NA. Three new arguments are added (before. . . ). check.names=FALSE and stringsAsFactors=FALSE are passed to data.frame whilereformatting the object returned by cast. The new argument reclass=TRUE is used to post-process the result: if TRUE, an attempt will be made to restore output columns to the class thatthe value column had before cast called as.vector on it. The attempt aborts unless thereexists a suitable ’as’ function for that class. This method returns a keyed data.frame whosekey is identical to id.vars. See also melt.keyed and examples there.

48 CLNR

check.subjects Summarize Columns of Subject Data

Description

This function checks for missing data, numeric data, ranges, etc. It is a tool developed to reviewdata that has been read into R.

Usage

check.subjects(x,subject)

Arguments

x data.frame

subject subject identifier in the data (column name)

Value

summary of each column in x by subject

Author(s)

Leonid Gibiansky, modified by Tim Bergsma

References

http://metrumrg.googlecode.com

CLNR Delete Files and Directories

Description

CLNR deletes files and directories and logs what was deleted to a text file in ‘project’.

Usage

CLNR(Dir, project, note = 'Files removed', test = TRUE)

closers 49

Arguments

Dir Complete path of directory to be deleted. This directory and all files and sub-directories will be deleted. Example: Dir=’/Dir/to/be/Removed’

project System path to the directory containing the NONMEM control (*.ctl) streams.

note character vector (defaults to ’Files removed’) for user text to describe why some-thing was deleted. Example: note=c(’Files removed ’)

test logical to determine if you want to actually delete the files or just see what fileswould be deleted. To delete directory, files, and sub-directories use test=F.

Author(s)

Bill Knebel

References

http://metrumrg.googlecode.com

closers Calculate Closing Text for Nested Script Levels

Description

Detect target locations for subscript and superscipt end-tags, and place the specified substitutes.

Usage

closers(x, sub, sup, ...)

Arguments

x character

sub character

sup character

... ignored

Details

Used by wikiparse.

Value

character

Author(s)

Tim Bergsma

50 codes

References

http://metrumrg.googlecode.com

See Also

• wikiparse

codes Recover Metadata from spec Objects and their Components

Description

A spec object has metadata stored compactly in its ‘label’ and ‘guide’ columns. Methods hereextract metadata, acting on the relevant column directly or on the object as a whole.

Usage

## Default S3 method:encoded(x, ...)## Default S3 method:codes(x, simplify=TRUE, ...)

## Default S3 method:decodes(x, simplify=TRUE, ...)## S3 method for class 'spec'

encoded(x, column=x$column, ...)## S3 method for class 'spec'

codes(x, column=x$column, ...)## S3 method for class 'spec'

decodes(x, column=x$column, ...)## S3 method for class 'spec'

labels(object, column=object$column, ...)## S3 method for class 'spec'guidetext(x, column=x$column, ...)

Arguments

x character, or spec

object character, or spec

simplify reduce a list to a vector if possible

column which column(s) to address

... ignored

codes 51

Details

encoded always returns TRUE or FALSE, telling whether the corresponding element represents anencoding of levels and labels. See encode. codes returns a list(or vector) giving the element-wisecodes (levels) or NA; decodes returns the corresponding decodes (labels) or NA. labels returnsthe descriptors for column names; don’t confuse with the labels for factor-like levels (decodes).guidetext returns the portion of a numeric guide element that is not a range specifier (if any): e.g.just ’kg’ for ’kg [0,30)’.

Value

list or vector

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.spec

• specfile

• specification

• encode

• extract

• %matches%

Examples

a <- encode(x = list(c('M','F'),c(1:4)

),labels = list(

c('male','female'),c('caucasian','asian','african',NA)

))b <- encode(c(1:2),c('pediatric','adult'))abc <- c('a',NA,'##b##')encoded(a)encoded(b)encoded(c)encoded(' //4// ')

52 colname<-

codes(a)codes(b)codes(b,simplify=FALSE)codes(c)codes('..1..')decodes(a)decodes(b)decodes(c)example(matches)

colname<- Change Selected Names

Description

Change selected element names.

Usage

colname(x) <- value

Arguments

x an object with named elements

value named character vector

Details

Changing column names is a common task. One can change them all at once, e.g.

colnames(x) <- c(...)

names(x) <- c(...)

or one at a time, e.g.

names(x)[names(x)==old] <- new

reshape supplies rename, a function that changes a subset of identified names, returning the objectitself.

library(reshape)

x <- rename(x, c(label=value,...))

In contrast, name and its data frame equivalent colname change a subset of identified names usingassignment syntax.

name(x) <- c(label=value,...)

Value

used for side effects

combinations 53

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• names

• colnames

Examples

names(Theoph)name(Theoph) <- c(Subject='SUBJECT')names(Theoph)colname(Theoph) <- c(SUBJECT='subject',conc='concentration')names(Theoph)names(letters) <- LETTERSlettersname(letters) <- c(A='a',B='b',C='c')letters

combinations Display Combinations of Column Values

Description

Generic, with method for data.frame. Display sorted unique rows.

Usage

## S3 method for class 'data.frame'combinations(x,key=names(x),depth=length(key),detect=character(0),count=FALSE,...)

54 combinations

Arguments

x object inheriting from data.frame

key columns to show first (default sort criteria)

depth integer up to length of key: actual sort criteria

detect columns to preprocess: non-NA values will be replaced with options(’defined’)or just ’defined’

count whether to tabulate the number of each unique row; logical, or length-one char-acter giving a column name for tabulations (default: ’count’)

... ignored

Details

Columns identified as ’key’ are moved to the front (by default, all).

Sorting cascades across the key columns, using the second column to break ties, etc. Permutationsof column order help to make patterns obvious.

Sorting can be limited to a subset of key columns using ’depth’.

Unique rows are displayed; the number of each such is tabulated as ’count’ if count is TRUE.Supply an alternate column name in place of TRUE, if you wish.

For column names in detect, all defined values are replaced with options(’defined’), which youcan manipulate (’defined’ by default). Useful when one wishes to examine patterns of missingness,rather than actual value details.

For keyed objects, the detect affect can be achieved more simply by subsetting with a leadingasterisk on column names. See examples.

Value

keyed data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.keyed

command 55

Examples

combinations(iris[,c('Species','Petal.Width','Sepal.Length')],detect='Sepal.Length',count=TRUE)# alternatively ...iris <- as.keyed(iris)combinations(iris[,c('Species','Petal.Width','*Sepal.Length')],count=TRUE)

command Format a Latex Command

Description

Format a latex command.

Usage

command(x, options = NULL, args = NULL, depth = 0)

Arguments

x length one character

options vector or list

args vector or list

depth integer

Details

x is formated as a latex command, with the options (possibly named) inserted in square brackets,and the arguments each enclosed in curly braces. depth spaces are added to the left end of thestring.

Value

character

Author(s)

Tim Bergsma

56 compileflag

References

http://metrumrg.googlecode.com

See Also

• wrap

• ltable.data.frame

• spaces

Examples

command('caption',options='short',args='long')

compileflag Develop a Value for a Compiler Resource on the Grid

Description

License management under Sun Grid Engine may require an argument to qsub of, e.g., ‘-l com-pile=1’ (in the case where the compiler is ‘ifort’). This function calculates that value flexibly.

Usage

compileflag(compiler, mappings = list(ifort = 1), ...)

Arguments

compiler name of the compiler in use

mappings values for the flag, per compiler

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runCommand

compiler 57

compiler Extract the Compiler Name from an NMQual Configuration File

Description

This function reads the configuration file and extracts the last path element of the first space-delimited component of the ‘nmtran’ instruction, typically a compiler name.

Usage

compiler(config, pathsep = '/', ...)

Arguments

config path for a configuration file

pathsep file system path separator

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runCommand

Examples

## Not run: compiler('../NONMEM/nm6osx1/test/config.xml'))

58 compute.cwres

compute.cwres Compute the Conditional Weighted Residuals

Description

This function computes the conditional weighted residuals (CWRES) from a NONMEM run. CWRESare an extension of the weighted residuals (WRES), but are calculated based on the first-order withconditional estimation (FOCE) method of linearizing a pharmacometric model (WRES are calcu-lated based on the first-order (FO) method). The function requires a NONMEM table file and anextra output file that must be explicitly asked for when running NONMEM. See details below.

Usage

compute.cwres(run.number,tab.prefix="cwtab",sim.suffix="",est.tab.suffix=".est",deriv.tab.suffix=".deriv",old.file.convention=FALSE,id="ALL",printToOutfile=TRUE,onlyNonZero=TRUE,...)

Arguments

run.number The run number of the NONMEM from which the CWRES are to be calculated.

tab.prefix The prefix to two NONMEM file containing the needed values for the computa-tion of the CWRES, described in the details section.

sim.suffix The suffix ,before the ".", of the NONMEM file containing the needed values forthe computation of the CWRES, described in the details section. For example,the table files might be named cwtab1sim.est and cwtab1sim.deriv, in whichcase sim.suffix="sim".

est.tab.suffix The suffix, after the ".", of the NONMEM file containing the estimated parame-ter values needed for the CWRES calculation.

deriv.tab.suffix

The suffix, after the ".", of the NONMEM file containing the derivatives of themodel with respect to the random parameters needed for the CWRES calcula-tion.

old.file.convention

For backwards compatibility. Use this if you are using the previous file conven-tion for CWRES (table files named cwtab1, cwtab1.50, cwtab1.51, ... , cwtab.58for example).

id Can be either "ALL" or a number matching an ID label in the datasetname.

compute.cwres 59

printToOutfile Logical (TRUE/FALSE) indicating whether the CWRES values calculated shouldbe appended to a copy of the datasetname. Only works if id="ALL". If chosenthe resulting output file will be datasetname.cwres.

onlyNonZero Logical (TRUE/FALSE) indicating if the return value (the CWRES values) ofcompute.cwres should include the zero values associated with non-measurementlines in a NONMEM data file.

tab.suffix The suffix to the NONMEM table file containing the derivative of the modelwith respect to the etas and epsilons, described in the details section.

... Other arguments passed to basic functions in code.

Details

compute.cwresThis function is the computational ’brains’ of the CWRES computation. The func-tion simply reads in the following two files:

paste(tab.prefix,run.number,sim.suffix,est.tab.suffix,sep="")paste(tab.prefix,run.number,sim.suffix,deriv.tab.suffix,sep="")

Which might be for example:

cwtab1.estcwtab1.deriv

and (depending on the input values to the function) returns the CWRES in vector form as well ascreating a new table file named:

paste(tab.prefix,run.number,sim.suffix,sep="")

Which might be for example:

cwtab1

Value

compute.cwres Returns a vector containing the values of the CWRES.

Setting up the NONMEM model file

In order for this function to calculate the CWRES, NONMEM must be run while requesting certaintables and files to be created. How these files are created differs depending on if you are using$PRED or ADVAN as well as the version of NONMEM you are using. These procedures areknown to work for NONMEM VI but may be different for NONMEM V. We have attempted toindicate where NONMEM V may be different, but this has not been extensively tested!

There are five main insertions needed in your NONMEM control file:

60 compute.cwres

1. 1. $ABB COMRES=X.Insert this line directly after your $DATA line. The value of X is the number of ETA() termsplus the number of EPS() terms in your model. For example for a model with three ETA()terms and two EPS() terms the code would look like this:

$DATA temp.csv IGNORE=@$ABB COMRES=5$INPUT ID TIME DV MDV AMT EVID$SUB ADVAN2 TRANS2

2. 2. Verbatim code.

• A. Using ADVAN.If you are using ADVAN routines in your model, then Verbatim code should be inserteddirectly after the $ERROR section of your model file. The length of the code dependsagain on the number of ETA() terms and EPS() terms in your model. For each ETA(y)in your model there is a corresponding term G(y,1) that you must assign to a COM()variable. For each EPS(y) in your model, there is a corresponding HH(y,1) term that youmust assign to a COM() variable.For example for a model using ADVAN routines with three ETA() terms and two EPS()terms the code would look like this:

"LAST" COM(1)=G(1,1)" COM(2)=G(2,1)" COM(3)=G(3,1)" COM(4)=HH(1,1)" COM(5)=HH(2,1)

• B. Using PRED.If you are using $PRED, the verbatim code should be inserted directly after the $PREDsection of your model file. For each ETA(y) in your model there is a corresponding termG(y,1) that you must assign to a COM() variable. For each EPS(y) in your model, there isa corresponding H(y,1) term that you must assign to a COM() variable. The code wouldlook like this for three ETA() terms and two EPS() terms:

"LAST" COM(1)=G(1,1)" COM(2)=G(2,1)" COM(3)=G(3,1)" COM(4)=H(1,1)" COM(5)=H(2,1)

3. 3. INFN routine.

• A. Using ADVAN with NONMEM VIb.If you are using ADVAN routines in your model, then an $INFN section should be placeddirectly after the $PK section using the following code. In this example we are assumingthat the model file is named something like ’1.ctl’. NOTE: Files 51, 53, 55 and 57 arenot used in the CWRES calculation and can be removed from the NONMEM model fileif problems arise due to failure of the $COV step in a NONMEM run.

compute.cwres 61

$INFNIF (ICALL.EQ.3) THENOPEN(50,FILE='cwtab1.est')WRITE(50,*) 'ETAS'DO WHILE(DATA)

IF (NEWIND.LE.1) WRITE (50,*) ETAENDDOWRITE(50,*) 'THETAS'WRITE(50,*) THETAWRITE(50,*) 'OMEGAS'WRITE(50,*) OMEGA(BLOCK)WRITE(50,*) 'SIGMAS'WRITE(50,*) SIGMA(BLOCK)

ENDIF

• B. Using ADVAN with NONMEM V.If you are using ADVAN routines in your model, then you need to use an INFN subrou-tine. If we call the INFN subroutine ’myinfn.for’ then the $SUBS line of your model fileshould include the INFN option. That is, if we are using ADVAN2 and TRANS2 in ourmodel file then the $SUBS line would look like:

$SUB ADVAN2 TRANS2 INFN=myinfn.for

The ’myinfn.for’ routine for 4 thetas, 3 etas and 1 epsilon is shown below. If your modelhas different numbers of thetas, etas and epsilons then the values of NTH, NETA, andNEPS, should be changed respectively. These vales are found in the DATA statement ofthe subroutine. Please note that the 4th and 5th lines of code should be one line with the’...’ removed from each line, reading: COMMON /ROCM6/ THETAF(40),OMEGAF(30,30),SIGMAF(30,30).NOTE: Files 51, 53, 55 and 57 are not used in the CWRES calculation and can be re-moved from the subroutine if problems arise due to failure of the $COV step in a NON-MEM run.

SUBROUTINE INFN(ICALL,THETA,DATREC,INDXS,NEWIND)DIMENSION THETA(*),DATREC(*),INDXS(*)DOUBLE PRECISION THETACOMMON /ROCM6/ ...... THETAF(40),OMEGAF(30,30),SIGMAF(30,30)COMMON /ROCM7/ SETH(40),SEOM(30,30),SESIG(30,30)COMMON /ROCM8/ OBJECTCOMMON /ROCM9/ IERE,IERCDOUBLE PRECISION THETAF, OMEGAF, SIGMAFDOUBLE PRECISION OBJECTREAL SETH,SEOM,SESIGDOUBLE PRECISION ETA(10)INTEGER J,IINTEGER IERE,IERCINTEGER MODEINTEGER NTH,NETA,NEPSDATA NTH,NETA,NEPS/4,3,1/IF (ICALL.EQ.0) THEN

C open files here, if necessaryOPEN(50,FILE='cwtab1.est')

62 compute.cwres

ENDIFIF (ICALL.EQ.3) THEN

MODE=0CALL PASS(MODE)MODE=1

WRITE(50,*) 'ETAS'20 CALL PASS(MODE)

IF (MODE.EQ.0) GO TO 30IF (NEWIND.NE.2) THEN

CALL GETETA(ETA)WRITE (50,97) (ETA(I),I=1,NETA)

ENDIFGO TO 20

30 CONTINUEWRITE (50,*) 'THETAS'WRITE (50,99) (THETAF(J),J=1,NTH)

WRITE(50,*) 'OMEGAS'DO 7000 I=1,NETA

7000 WRITE (50,99) (OMEGAF(I,J),J=1,NETA)WRITE(50,*) 'SIGMAS'

DO 7999 I=1,NEPS7999 WRITE (50,99) (SIGMAF(I,J),J=1,NEPS)

ENDIF99 FORMAT (20E15.7)98 FORMAT (2I8)97 FORMAT (10E15.7)

RETURNEND

• C. Using $PRED with NONMEM VIb.If you are using $PRED, then an the following code should be placed at the end of the$PRED section of the model file (together with the verbatim code). NOTE: Files 51,53, 55 and 57 are not used in the CWRES calculation and can be removed from theNONMEM model file if problems arise due to failure of the $COV step in a NONMEMrun.

IF (ICALL.EQ.3) THENOPEN(50,FILE='cwtab1.est')WRITE(50,*) 'ETAS'DO WHILE(DATA)

IF (NEWIND.LE.1) WRITE (50,*) ETAENDDOWRITE(50,*) 'THETAS'WRITE(50,*) THETAWRITE(50,*) 'OMEGAS'WRITE(50,*) OMEGA(BLOCK)WRITE(50,*) 'SIGMAS'WRITE(50,*) SIGMA(BLOCK)

compute.cwres 63

ENDIF

• D. Using $PRED with NONMEM V.If you are using $PRED with NONMEM V, then you need to add verbatim code imme-diately after the $PRED command. In this example we assume 4 thetas, 3 etas and 1epsilon. If your model has different numbers of thetas, etas and epsilons then the valuesof NTH, NETA, and NEPS, should be changed respectively. These vales are found in theDATA statement below. Please note that the 3rd and 4th lines of code should be one linewith the ’...’ removed from each line. NOTE: Files 51, 53, 55 and 57 are not used inthe CWRES calculation and can be removed from the NONMEM model file if problemsarise due to failure of the $COV step in a NONMEM run.

$PRED"FIRST" COMMON /ROCM6/ ......THETAF(40),OMEGAF(30,30),SIGMAF(30,30)" COMMON /ROCM7/ SETH(40),SEOM(30,30),SESIG(30,30)" COMMON /ROCM8/ OBJECT" DOUBLE PRECISION THETAF, OMEGAF, SIGMAF" DOUBLE PRECISION OBJECT" REAL SETH,SEOM,SESIG" INTEGER J,I" INTEGER MODE" INTEGER NTH,NETA,NEPS" DATA NTH,NETA,NEPS/4,3,1/

After this verbatim code you add all of the abbreviated code needed for the $PRED rou-tine in your model file. After the abbreviated code more verbatim code is needed. Thisverbatim code should be added before the verbatim code discussed above under point 2.

" IF (ICALL.EQ.0) THEN"C open files here, if necessary" OPEN(50,FILE='cwtab1.est')" ENDIF" IF (ICALL.EQ.3) THEN" MODE=0" CALL PASS(MODE)" MODE=1" WRITE(50,*) 'ETAS'" 20 CALL PASS(MODE)" IF (MODE.EQ.0) GO TO 30" IF (NEWIND.NE.2) THEN" CALL GETETA(ETA)" WRITE (50,97) (ETA(I),I=1,NETA)" ENDIF" GO TO 20" 30 CONTINUE" WRITE (50,*) 'THETAS'" WRITE (50,99) (THETAF(J),J=1,NTH)" WRITE (50,*) 'OMEGAS'" DO 7000 I=1,NETA" 7000 WRITE (50,99) (OMEGAF(I,J),J=1,NETA)

64 compute.cwres

" WRITE (50,*) 'SIGMAS'" DO 7999 I=1,NEPS" 7999 WRITE (50,99) (SIGMAF(I,J),J=1,NEPS)" ENDIF" 99 FORMAT (20E15.7)" 98 FORMAT (2I8)" 97 FORMAT (10E15.7)

4. 4. cwtab*.deriv table file.

A special table file needs to be created to print out the values contained in the COMRES vari-ables. In addition the ID, IPRED, MDV, DV, PRED and RES data items are needed for thecomputation of the CWRES. The following code should be added to the NONMEM modelfile. In this example we continue to assume that we are using a model with three ETA() termsand two EPS() terms, extra terms should be added for new ETA() and EPS() terms in themodel file.

$TABLE ID COM(1)=G11 COM(2)=G21 COM(3)=G31COM(4)=H11 COM(5)=H21IPRED MDV NOPRINT ONEHEADER FILE=cwtab1.deriv

5. 5. $ESTIMATION.

To compute the CWRES, the NONMEM model file must use (at least) the FO method withthe POSTHOC step. If the FO method is used and the POSTHOC step is not included then theCWRES values will be equivalent to the WRES. The CWRES calculations are based on theFOCE approximation, and consequently give an idea of the ability of the FOCE method to fitthe model to the data. If you are using another method of parameter estimation (e.g. FOCEwith interaction), the CWRES will not be calculated based on the same model linearizationprocedure.

Author(s)

Andrew Hooker

References

Hooker A, Staatz CE, Karlsson MO. Conditional weighted residuals, an improved model diagnos-tic for the FO/FOCE methods. PAGE 15 (2006) Abstr 1001 [http://www.page-meeting.org/?abstract=1001].

See Also

• compute.cwres

config 65

config Identify the Configuration File in an NMQual-mediated NONMEM in-stallation.

Description

Gives the path for the configuration file in a NONMEM installation directory.

Usage

config(dir, ...)

Arguments

dir directory in which to find ‘config.xml’

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runNonmem

Examples

config('/common/nonmem/nm6')

66 constant

constant Test for Nested Factors

Description

Various Tests for Nested Factors.

Usage

crosses(a, b, all = FALSE)a %nests% ba %nested.in% ba %crosses% ba %crossed.on% b## Default S3 method:constant(x,within=rep(TRUE,length(x)),...)

Arguments

a a factor, something coercible to a factor, or a list of such having equal lengths(e.g. data.frame)

b like a, possibly a different number of factors, but same length(s)

all whether to include first instances: see details

x an object like a

within An object like b

... extra arguments passed to other methods

Details

We propose an idiom pertaining to two factors (or interactions) of equal length, in which either acrosses b, or b nests a. Equivalently, in the former case we could say b is crossed on/by a; in thelatter we could say a is nested in b. In the case that b nests a, it must be true that b is constantwithin a. For example, if treatment nests replicate, then for multiple observations of a single levelof replicate, all observations of treatment must be the same. The value of replicate implies the valueof treatment (though the reverse need not be true).

Formally, a crosses b if any level of a is associated with more than one level of b. In this case, b isnot constant within a. If you are wondering why !constant(x,y), examine crosses(y,x).

crosses() is the basis for all other functions, and is useful for determining positions at whichcrossing occurs (or nesting fails). For each level of a, it returns FALSE for the first unique value ofb, and TRUE for any others. If all is TRUE, however, it returns TRUE for the first unique value ofb when there are others.

For the following equivalency table, all assertions in a row are true if any of them is true.

crosses crossed.on nests nested.in constanta %crosses% b b %crossed.on% a !b %nests% a !a %nested.in% b !constant(b,within = a)

constant 67

b %crosses% a a %crossed.on% b !a %nests% b !b %nested.in% a !constant(a,within = b)!a %crosses% b !b %crossed.on% a b %nests% a a %nested.in% b constant(b,within = a)!b %crosses% a !a %crossed.on% b a %nests% b b %nested.in% a constant(a,within = b)

Value

Logical vector for crosses(); scalar logical for all others.

Note

All these functions are NA-safe; i.e., they treat NA as a distinct level.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

CO2[,c('Type','Treatment')] %nests% CO2$Plant #TRUECO2$Plant %nested.in% CO2$Type #TRUEwith(CO2,constant(list(Type,Treatment),within=Plant)) #TRUEwith(ChickWeight,constant(Diet,within=Chick)) #TRUEwith(ChickWeight,constant(weight,within=list(Chick,Time))) #TRUEcrosses(c(1,1,1),c(1,2,3)) # FALSE TRUE TRUEcrosses(c(1,1,1),c(1,2,2)) # FALSE TRUE TRUEcrosses(c(1,1,1),c(2,2,1)) # FALSE FALSE TRUEcrosses(c(1,1,1),c(1,2,3), all=TRUE) # TRUE TRUE TRUEcrosses(c(1,2,3),c(1,1,1)) # FALSE FALSE FALSEcrosses(c(NA,2,3),c(NA,NA,NA)) # FALSE FALSE FALSEconstant(Theoph$Wt,within=Theoph$Subject)#TRUEtrt <- c('a','a','a','b')rep <- c(1,1,2,3)trt %crosses% rep # TRUErep %nests% trt # FALSEtrt %nests% rep # TRUErep %nested.in% trt # TRUErep %crosses% trt # FALSEtrt %crossed.on% rep #FALSEconstant(trt,within=rep) # TRUE

68 contains

contains Test a Character Vector for Occurences of a Pattern

Description

Test a character vector for occurences of a pattern.

Usage

contains(pattern, text, ...)x %contains% y

Arguments

pattern regular expression

text character vector

... extra arguments to regexpr

x vector

y pattern to seek in x

Details

Each element of text is tested for pattern, and returns TRUE if pattern matches. The binaryoperator version implements a more natural syntax.

Value

logical vector as long as text

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• regexpr

convertLines 69

Examples

contains('glu',c(

'glucose','glucuronidase','glucogen','fibrogen'

))letters %contains% 'a'

convertLines Convert Line Endings

Description

Convert line endings to local encoding, by default.

Usage

convertLines(source,destination=source,...)

Arguments

source file path

destination file path

... passed to readLines and writeLines

Details

By default, the source file is overwritten with lines terminating in the local line ending.

Value

Used for side effects.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

70 css

See Also

• readLines

• writeLines

css Calculate One-Compartment Model Properties

Description

These functions calculate steady-state properties from the parameters of a one-compartment phar-macokinetic model, assuming all doses occur in the post- distribution phase (tau » tmax).

Usage

acr(cl, v, tau, ...)cavg(cl, tau, dose, ...)cmax(cl, v, ka, tau, dose, ...)cmin(cl, v, ka, tau, dose, ...)css(cl, v, ka, tau, dose, time, ...)ke(cl, v, ...)tmax(cl, v, ka, tau, ...)auc(cl, dose, ...)

Arguments

cl apparent clearance (L/h)

v apparent volume (L)

ka absorption constant (h−1)

tau steady-state trough-to-trough interval (h)

dose dose (arbitrary units)

time arbitrary time point, <= tau

... other arguments, ignored

Details

acr calculates accumulation ratio (unitless, called by css). ke calculates the elimination constant(h−1, called by css). css calculates steady-state compartment concentration (dose units per L) ata given time. cavg calculates average concentration over dosing interval. cmin and cmax calculateminimum and maximum steady-state concentrations; they call css, passing either tau itself or tmaxfor the time argument. tmax calculates the time of the maximum concentration. auc calculates areaunder the curve.

Note that for the post-distributive assumption to hold, tau must be very large relative to the timeneeded for drug disposition. To the extent that it does not hold, these functions give biased results.

cv 71

Value

numeric

Note

Multiple properties can be calculated within the same function or loop, since all arguments can bepassed even if not needed. For example, the same five arguments can be passed, even un-named, tocmax and tmax (tmax will ignore dose). But be sure to pass by name the same arguments to cmaxand cavg: the latter will ignore unused arguments but has the common arguments in a differentorder.

Author(s)

Tim Bergsma

References

Gibaldi M, Perrier D. Multiple dosing. Pharmacokinetics. New York: Marcel Dekker, Inc., 1982:p. 113- 144.

Examples

cavg(cl=0.05,tau=300,dose=100)cmax(cl=0.05,v=10,ka=0.015,tau=300,dose=100)cmin(cl=0.05,v=10,ka=0.015,tau=300,dose=100)tmax(cl=0.05,v=10,ka=0.015,tau=300)

cv Compute Coefficient of Variation for Normal and Log-Normal Data.

Description

The CV for normally distributed data can be calculated as a function of variance and mean.

The CV for log-normally distributed data can be calculated as a function of the variance of thelog-transformed data. See references below.

Usage

cvNormal(var,mean, ...)cvLognormal(var, ...)

Arguments

var variance of the normal data or log-transformed lognormal data

mean mean of the normal data

... ignored

72 dataFormat

Value

numeric

Author(s)

Tim Bergsma

References

http://en.wikipedia.org/wiki/Coefficient_of_variation

http://en.wikipedia.org/wiki/Log-normal_distribution#Coefficient_of_variation

http://tolstoy.newcastle.edu.au/R/help/05/12/16710.html

See Also

• percent

Examples

norm <- rnorm(10000,mean=10,sd=5)lnrm <- rlnorm(10000,meanlog=10,sdlog=.3)cvNormal(sd(norm)^2,mean(norm))cvLognormal(sd(log(lnrm))^2)

dataFormat Integrate NONMEM Data for Plotting

Description

Integrates data.frames representing standard NONMEM output and the source data.

Usage

dataFormat(tabdata,covdata,pardata,logtrans = FALSE,grp = NULL,grpnames = NULL,cont.cov = NULL,cat.cov = NULL,par.list = NULL,eta.list = NULL,missing = -99,run,...)

dataFormat 73

Arguments

tabdata data.frame for ‘*.TAB’

covdata data.frame for underlying dataset,one record per ID

pardata data.frame for ‘*par.TAB’

logtrans see PLOTR

grp see PLOTR

grpnames see PLOTR

cont.cov see PLOTR

cat.cov see PLOTR

par.list see PLOTR

eta.list see PLOTR

missing see PLOTR

run see PLOTR

... passed to synthesis

Details

Called by dataSynthesis, and in turn calls synthesis.

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• dataSynthesis

• synthesis

74 dataSynthesis

dataSynthesis Build a Standard Plotting Data Set for a Given NONR Run

Description

dataSynthesis scavenges columns from the ‘TAB’ file, the ‘par.TAB’ file, and the underlyingdataset (all required), returning just observation records (EVID==0) that are not commented. Thesecond two files are limited to the first record per ID. Columns to scavenge are supplied by grp, cont.cov, cat.cov, par.list, and eta.list.All ‘TAB’ file columns are returned, plus first instance of ‘scavenge’ columns from either the ‘par’file or the parent data set (in that order) unless already present. Exception: par.list and eta.listitems are not sought in the underlying dataset.

Usage

dataSynthesis(run,project=getwd(),logtrans = FALSE,grp = NULL,grpnames = NULL,cont.cov = NULL,cat.cov = NULL,par.list = NULL,eta.list = NULL,missing = -99,rundir = filename(project, run),ctlfile = filename(rundir,run,'.ctl'),outfile = filename(rundir,run,'.lst'),datfile = getdname(ctlfile),...)

Arguments

run a control stream name, typically integer

project the directory containing the NONMEM run directories

logtrans whether to transform the NONMEM output variables DV, PRED, and IPRED.Default: FALSE.

grp item in NONMEM datafile or output table file that can be used to condition plotsgenerated by PLOTR. Default value is NULL. Example: grp=c(’SEX’). Can bemore than one, e.g,. grp=c(’SEX’,’TRT’).

grpnames optional vector of names for grp item. Vector length must equal number ofconditions in grp and must have an order corresponding to an increasing sort ofgrp. Default value is NULL. Example: grpnames=c(’Male’,’Female’)

dataSynthesis 75

cont.cov vector of continuous covariate names. Names must match those used as columnheaders in datfile. Values are retrieved from datfile so they do not needto be part of the NONMEM $TABLE step. Default value is NULL. Example:cont.cov=c(’AGE’,’WT’,’CLCR’)

cat.cov vector of categorical covariate names. Names must match those used as columnheaders in datfile. Values are retrieved from datfile so they do not needto be part of the NONMEM $TABLE step. Default value is NULL. Example:cat.cov=c(’SEX’,’FOOD’)

par.list vector of NONMEM model parameter names. Values are retrieved from ‘*par.TAB’created in NONMEM. Default value is NULL. This can be a superset of param-eters but only those present in NONMEM output table will be used. Example:par.list=c(’CL’,’V’,’V2’,’Q’)

eta.list vector of NONMEM model random effect names. Values are retrieved from‘*par.TAB’ created in NONMEM. Default value is NULL. This can be a supersetof random parameters but only those present in NONMEM output table will beused. Example: eta.list=c(’ETA1’,’ETA2’,’ETA3’,’ETA4’)

missing numeric item that defines value used to represent missing items in the NON-MEM data file. Default value is ’-99’.

ctlfile Path and filename for the NONMEM control stream (‘*.ctl’).

outfile Path and filename for the NONMEM output file (‘*.lst’).

datfile Path and filename for the source dataset, as in DATA record in ‘*.ctl’.

rundir Path for the NONMEM run directory (‘project/*’).

... extra arguments

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• diagnosticPlots

• dataFormat

76 deranged

deranged Modify Assembly of nm Objects

Description

These are special preparations of nm objects or their sources. Proxy methods for Ops.keyed aretechniques for dynamic preparation. Deprecated, except for deranged.

Usage

## S3 method for class 'nm'moot(x,scope = x$EVID == 2,disregard = c('TIME', 'DATETIME', 'DATE', 'TAFD', 'TAD','HOUR'),...)## S3 method for class 'nm'rig(x, n = 50, dateTime = FALSE, noDups = FALSE, ...)## S3 method for class 'keyed'deranged(x, ...)## S3 method for class 'data.frame'deranged(x, start, stop, result = start, dropStop = TRUE, ...)

as.moot(...)as.rigged(...)

minus.moot(x, y, ...)plus.rigged(x, y)

Arguments

x dispatch argumenty right operand to proxy methodstart name of column with start valuesstop name of column with stop valuesresult name of column in which to place the resultdropStop whether to drop the stop column before returning... extra arguments, usually ignored; see detailsscope an expression to evaluate within x, giving moot candidate rowsdisregard columns to disregard when testing for between-row differencesn number of extra records to generate per subjectdateTime whether to attempt derivation of timecourse from DATETIME instead of HOURnoDups whether to prohibit introduction of rows with times that already exist

deranged 77

Details

deranged.data.frame. When a dataset attribute (column) is constant over some range of anotherdiscreet attribute, information may be stored more compactly by specifying the constant attributeonce, together with the start and stop of the range. This function takes such a dataset and instan-tiates all implied records. Warning: the function calls seq(start,stop) for each row, and makesno assumptions about whether the data is ascending, descending, stationary (start==stop), or un-defined (one or more of start and stop is NA). deranged.keyed is just a wrapper that preservesattributes.

moot.nm will identify rows that make no difference to NONMEM. If an EVID:2 row differs fromthe row just before it only with respect to timepoint designations, the NONMEM result should notbe affected. NONMEM should use the changed values from the first row in which non-timepointitems change to estimate the midpoint of the prior interval.

rig.nm generates extra rows, spaced across each subject’s timecourse, for obtaining model pre-dictions in NONMEM (EVID: 2). It cannot work with HOUR and DATETIME simultaneously, so inmixed cases, plus.rigged tries both sequentially and combines the result.

as.moot and as.rigged return their arguments as a list classified as moot or rigged, respectively.In operator context, - as.moot or + as.rigged cause minus.moot or plus.rigged to be called.These call moot and rig with the left operand as x and the right operand as a list of extra argu-ments; then they do appropriate processing. minus.moot drops moot rows; plus.rigged mergesthe rigged data.frame.

deranged and moot can be used together with effect. deranged creates explicit rows that can bemerged by TIME to existing data. After the merge, it will be apparent that many such rows are moot.Functions here support dynamic removal. See example for as.nm.

Value

moot.nm returns logical, with length nrow(x). as.moot returns a list of class moot. minus.mootreturns a subset of its first argument, typically nm.

rig.nm returns a data.frame of rows evenly spaced across each subject’s timecourse (i.e., ‘rigging’).as.rigged returns a list of class rigged. plus.rigged returns a merge on its first argument,typically nm.

deranged returns keyed data.frame.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.nm

• Ops.keyed

78 diagnosticPlots

diagnosticPlots Create Diagnostic Plots

Description

Create diagnostic plots from a data set.

Usage

diagnosticPlots(data,dvname='DV',group=NULL,model=NULL,include.all=FALSE,variant=NULL,...)

covariatePlots(data,cont.cov=NULL,cat.cov=NULL,par.list=NULL,eta.list=NULL,...)

cwresPlots(data,cont.cov=NULL,cat.cov=NULL,variant=NULL,...)

Arguments

data a data.frame, typically created by dataSynthesis

dvname name of the dependent variable to use as a label for the diagnostic plots

group optionally, a column name in data used to condition the output of diagnosticPlots

model If supplied, this text argument will be prepended to the figure titles.

include.all When group is specified, should plots be generated as well, for all data collec-tively?

variant residual variant; see details

digest 79

cont.cov as defined for PLOTR

cat.cov as defined for PLOTR

par.list as defined for PLOTR

eta.list as defined for PLOTR

... ignored arguments

Details

PLOTR passes the result of dataSynthesis to these functions and prints the resulting lists (of trellisobjects) on the open device.

variant is a vector including one or more of the following: RES, NRES, WRES, NWRES, CRES,CWRES, RESI, WRESI, CRESI, CWRESI, CIRES, CIWRES, CIWRESI, ERES, EWRES, orECWRES. cwresPlots originally handled just CWRES, but now handles any supplied variant innames(data).

Value

a list of trellis objects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

• dataSynthesis

digest Diagnose Static Data Relationships

Description

Break a data frame into components static on variants of a proposed key.

80 digest

Usage

## S3 method for class 'digest'as.best(x, ...)## S3 method for class 'data.frame'as.digest(x, key = character(0), strict = TRUE, ...)## S3 method for class 'digest'as.digest(x, ...)## S3 method for class 'keyed'as.digest(x, key = match.fun("key")(x), strict = TRUE, ...)## S3 method for class 'nm'as.digest(x,key=match.fun('key')(x),...)## S3 method for class 'nm'as.keyed(x, key = match.fun("key")(x), ...)## S3 method for class 'digest'head(x, ...)

Arguments

x object of dispatch

key a vector of column names in x representing a proposed object hierarchy

strict passed to lyse

... passed to or from other functions

Details

Well-constructed data tables typically admit a set of columns (a key), the interaction of whichuniquely distinguish all rows. The columns may be ordered from most general to most specific,in which case they may be thought of as an object hierarchy. The hierarchy accounts for structuralredunancy of identifier variables across rows. When exploring data, it may be useful to remove suchredundancy to focus on singular relationships within the data (e.g., like static).

digest recursively cleaves a data frame using appropriate subsets of a key. The original data frameand any dynamic residuals are cleaved using increasingly longer left subsets (empty; 1; 1,2; 1,2,3;etc.) of the proposed key. Effectively, this is a search for columns that are static on (i.e. are attributesof) various objects and sub-objects. The static results of cleaving, if any, are further explored (ifpossible) with increasingly shorter right subsets (e.g. 1,2,3; 2,3; 3) to detect any columns that aresuper-keyed: i.e. are still strictly attributes of some sub-object, without appeal to more generalhierarchical levels. digest returns a list of keyed data frames, such that each original non-keycolumn appears in exactly one data frame, together with the smallest necessary set of key columns,and all siblings (like-keyed non-key columns). If indeed the proposed key completely distinguishesall rows, the result consists only of static data frames. Otherwise, the last data frame is dynamic.For columns that are constant in the data, irrespective of the proposed key, the key of the sub-resulthas length zero. The resulting key for a dynamic sub-result is the last key tried (possibly differentfrom the proposed key, as elements may be removed from consideration if they are themselves staticon some prior key). Elements are named with their keys, pasted together with dots; except if thekey is character(0), the name will be a single dot, or two dots for the last element if it is dynamic onthe proposed key.

electronicAppendix 81

Value

as.digest and as.best.digest return an object of class digest: a list of keyed data frames, withnames suggesting their keys (’.’ for character(0), ’..’ for a dynamic data frame).

Note

digest is an alias for the generic as.digest.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.keyed

• static

• index

Examples

digest(Theoph,c('Subject','Time'))head(digest(Theoph,c('Subject','Time')))

electronicAppendix Make an FDA-style Electronic Appendix from a Subversioned Direc-tory.

Description

Make an FDA-style Electronic Appendix from a Subversioned Directory.

Usage

electronicAppendix(x, as,pattern = NULL,recursive = TRUE,ignore.case = TRUE,zip = FALSE,...)

82 electronicAppendix

Arguments

x a Subversioned directory, e.g. a checkout of a repository or subdirectory thereof.

as a file path for a directory to be created

pattern passed to dir

recursive passed to dir

ignore.case passed to dir

zip logical indicating whether to compress as to a zipped file.

... ignored

Details

FDA submissions may require electronic copies of file trees, where text files must have the extension‘txt’. This function creates a copy of x using svn export (a system call). It fixes the names of thosefiles that Subversion considers text, and optionally compresses the resulting directory to a zippedfile (also a system call). Not tested on all platforms, but should work fine on most Unix-alikes.

For finer control over what is considered text, see svnMarkAsText and svnMarkAsNonText.

Note that non-subversioned files will not be included in the electronic appendix. An error results ifany file is subversioned but missing.

as must be specified as a directory name. If zip is TRUE, .zip will be added.

as cannot pre-exist unless zip is true, in which case as will be renamed temporarily while itsnamesake is zipped and unlinked.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• dir

• svnIsText

• svnMarkAsText

• svnMarkAsNonText

encode 83

encode Encode Factor-like Levels and Labels as a Simple String

Description

For compact storage, encode combines a set of levels and labels (codes and decodes) into a simplestring. The default method converts its argument to character. The list method operates element-wise, expecting and equal number of label elements, each of which have the same length as thecorresponding element of x.

Usage

## Default S3 method:encode(x, labels = NULL, sep = '/',...)## S3 method for class 'character'encode(x, labels = NULL, sep = '/',...)## S3 method for class 'list'encode(x, labels = NULL, sep = '/',...)

Arguments

x typically character

labels typically character

sep character

... ignored

Details

An ’encoding’ must be at least 5 characters long, beginning and ending with two instances of sep.Specified levels are likewise separated by double separators. If a label (decode) is available for alevel, it follows the corresponding level: the two are separated by a single instance of sep. Separa-tors may be mixed within an encoded vector, but not within an element. --0-male--1-female--indicates that the value 0 represents the concept "male" and the value 1 represents "female".

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

84 episcript

See Also

• as.spec

• specfile

• specification

• codes

• %matches%

Examples

a <- encode(x = list(c('M','F'),c(1:4)

),labels = list(

c('male','female'),c('caucasian','asian','african',NA)

))b <- encode(c(1:2),c('pediatric','adult'))ab

episcript Run an Epilog Script in a Pre-populated Environment

Description

Sources the named script in an environment where all other passed arguments (...) have been definedby assignment.

Usage

episcript(script, ...)

Arguments

script path for an R script

... variables with which to populate the script’s environment

Value

used for side effects

Author(s)

Tim Bergsma

extract 85

References

http://metrumrg.googlecode.com

See Also

• runNonmem

extract Extract a Parenthetically-grouped Substring of a Regular Expression

Description

Given a regular expression with parenthetically-grouped substrings, return or drop the substring ofinterest.

Usage

extract(x, pattern, group = 0, invert = FALSE, ...)

Arguments

x character

pattern passed to regexec

group one less than the index used by regexec

invert drop the matched text, returning everything else

... ignored

Details

regexec determines all the numbered matches corresponding to sets of parentheses. extract usesthese to locate and return particular numbered matches, or to delete them, returning what remains.group = 0 refers to the entire match (first element of each regexec result). Non-matches give anempty string; matching NA results in NA.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

86 filename

See Also

• regexec

• guidetext

Examples

x <- c(' kg ',' //a/A//b/B// ',NA,' kg [ 4 , 8.2 ]','(,1.025e-6]','(,] ')pattern <- '((\\(|\\[) *([-+eE.0-9]*) *, *([-+eE.0-9]*) *(\\)|\\])) *$'extract(x,pattern,group=5)

filename Construct a Canonical File Name

Description

Helper function to build file and directory names from components.

Usage

filename(dir, run = NULL, ext = NULL)

Arguments

dir directory

run run name

ext file extension

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• dataSynthesis

Examples

filename('dir','3','.ctl')

findNonmemCommand 87

findNonmemCommand Find Paths to Available Nonmem Commands

Description

NONR takes the path to a NONMEM executable as its command argument. Discovery can be anissue. This command sets probable defaults and searches for exact paths.

Usage

findNonmemCommand(under=c('/opt/NONMEM','/opt/nonmem'),executable='autolog.pl',...)

Arguments

under a directory for NONMEM installations

executable file name sought

... passed to dir

Details

Arguments are simply passed through to dir.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• NONR

88 first

first Identify Elements Within Cells Meeting Some Instance of a Condition

Description

Within each level of within, find the nth element for which where is TRUE, and repeat it at allpositions in the level.

Usage

nth (x,where,within,n=1,...)first(x,where,within,...)last (x,where,within,...)only (x,where,within,...)distance(where,within,n=1,...)before( where,within,n=1,...)at( where,within,n=1,...)after( where,within,n=1,...)

Arguments

x vector (possibly factor)where vector, coerced to logicalwithin a vector or list of vectors serving as an indexn an integer giving the instance of interest... ignored arguments.

Details

nth returns, for each position in x, the nth element of x, optionally limiting candidate elements bywhere, and optionally breaking the evaluation across subsets as specified by within. n can be 0,returning all NA, or negative, which counts instances from the end of the vector or subsets. If n isNA, all elements are returned. NA is returned at positions for which the condition where is not metn times.

All of x, where, and within are optional. The ‘scale’ of the function is set to the longest of the three(member-wise for within if it is a list). Missing x is replaced with the subscripts implied by ‘scale’.Missing where and within are replaced with TRUE, repeated to length ’scale’. No warnings aregiven if within has NA, or list members with different lengths.

first and last are convenience wrappers for nth that set n to 1 and -1, respectively. only is likefirst, but returns NA if a second instance exists.

distance returns subscripts less the nth subscripts, optionally considering where and within.before, at, and after test whether distance is less than, equal to, or greater than zero.

Value

vector of same class as x, if supplied, else of class integer. Logical for before, at, and after.

fixedwidth 89

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• match

Examples

first(1:10)first(1:10,within=rep(1:2,each=5))last( 1:10,within=rep(1:2,each=5))first(1:10,where=0:1,within=rep(1:2,each=5))test <- data.frame(id=c(1,1,1,1,1,2,2,2,2,2),time=c(1,2,3,4,5,1,2,3,4,5),evid=c(0,1,0,1,0,1,0,1,0,1))test$secondDose <- with(test,nth(where=evid==1, n=2,within=id))test$lastDose <- with(test,nth(where=evid==1,n=-1,within=id))test$beforeDose2 <- with(test,before(where=evid==1, n=2,within=id))test$tafd <- with(test,time - first(time,where=evid==1,within=id))#time after first dosetest# id time evid secondDose lastDose beforeDose2 tafd# 1 1 1 0 4 4 TRUE -1# 2 1 2 1 4 4 TRUE 0# 3 1 3 0 4 4 TRUE 1# 4 1 4 1 4 4 FALSE 2# 5 1 5 0 4 4 FALSE 3# 6 2 1 1 8 10 TRUE 0# 7 2 2 0 8 10 TRUE 1# 8 2 3 1 8 10 FALSE 2# 9 2 4 0 8 10 FALSE 3# 10 2 5 1 8 10 FALSE 4only(1:9,where= c(0,1,0, 1,0,1, 0,0,0),within=c(1,1,1, 2,2,2, 3,3,3))#[1] 2 2 2 NA NA NA NA NA NA

fixedwidth Apply Fixed-width Formatting to a Data Frame

90 fixedwidth

Description

Generic, with a method for data.frame that right-justifies headers and columns, padding with spaces.

Usage

## S3 method for class 'data.frame'fixedwidth(x, ...)

Arguments

x a data.frame

... extra arguments, ignored

Details

There does not seem to be a way to get write.table to produce fixed-width output. fixedwidth.data.framegives essentially the same result as print.data.frame. Columns and headers are padded, suitablefor output to a file using the defaults for write.table (sep=’ ’).

Value

data.frame; all columns are character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• write.table

Examples

fixedwidth(head(Theoph))

fixProblem 91

fixProblem Clean Up a Control Stream

Description

These functions are used to re-write a control stream for NONR(checkrunno=TRUE,...).

Usage

fixProblem(x,run)fixFile(x,run)explicitPath(x)extractPath(x)resolve(file,dir)scavenge(expr,lines)extfile(ctlfile,dir,extreg,...)tabfile(ctlfile,dir,tabreg='(?<!par)\\.tab',...)parfile(ctlfile,dir,parreg='par\\.tab',...)msffile(ctlfile,dir,msfreg='^(?!\$MSFI).*\\.msf',...)

Arguments

x character vector, i.e. read from control stream file

run run designator to substitute at predefined locations

file an absolute or relative filepath

dir a directory

expr a regular expression to locate relevant lines

lines lines in which to search for expr

ctlfile character vector representing the control stream

extreg a regular expression to locate an arbitrary file

tabreg a regular expression to locate the ‘.TAB’ file

parreg a regular expression to locate the ‘par.TAB’ file

msfreg a regular expression to locate the ‘.MSF’ file

... ignored

Details

fixProblem tries to substitute the run name in the NONMEM $PROBLEM statement with thecurrent run name. It looks for any number of leading spaces, and then RUN or RUN\# (optional).The next space delimited word is replaced.

fixFile tries to replace the run name in filenames ending in ‘.msf’, ‘par.tab’, or ‘.tab’. Cur-rently it relies on dirname and basename, which use the same file separator on ’Nix and Windows.basename fails if there is no path separator, e.g., FILE=40.tab. fixFile pre-processes its argument

92 fixProblem

with explicitPath, as a work-around. Lines containing ‘MSFI’ formerly were coerced using ex-plicit paths, but are now ignored.

explicitPath finds lines that contain ‘.tab’ or ‘.msf’ but not ‘/’. It tries to place ‘./’ before‘run.msf’ or ‘run.tab’.

‘extractPath’ isolates the file portion of a line of text. The file portion consists of a sequence ofnonspace characters following ‘MSF=’, ‘MSFO=’, or ‘FILE=’. Spaces may occur before and afterthe equality sign. This function is currently used by runNonmem to locate the tabfile, parfile, andmsffile.

resolve does nothing to absolute filepaths in file, but expresses others (those beginning with ‘.’)relative to dir.

tabfile, parfile, and msffile calculate corresponding filepaths from their arguments, relying onextfile as the common engine.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runNonmem

• dataSynthesis

Examples

prob <- c('$ 1000 desc','$1000 desc','$RUN1000 desc','$ RUN#1000 desc','$ RUN# 1000 desc')fixProblem(prob,2000)msf <- c('$EST MAXEVAL=9999 MSF=../1000.MSF',#standard'$EST MAXEVAL=9999 msf=../1000.MSF',#case change'$EST MAXEVAL=9999 MSF = ../1000.MSF',#one or two spaces'$EST MAXEVAL=9999 MSFO=../1000.MSF',#optional O'$EST MAXEVAL=9999 MSF=../1000.msf',#case change'$EST MAXEVAL=9999 MSF=../1000.msf INTER',#trailing text'$EST MAXEVAL=9999 MSF=../1000/1000.msf',#non-target path elements'$EST MAXEVAL=9999 MSF=1000.msf',#no path

ftable2data.frame 93

'$MSFI 1000.MSF',#non-target file name'$INPUT etc'#non-target)fixFile(msf,2000)tab <- c('ONEHEADER NOPRINT FILE=../1000.TAB','ONEHEADER NOPRINT FILE = ../1000.TAB','ONEHEADER NOPRINT FILE=../1000par.TAB','ONEHEADER NOPRINT file=../1000par.tab','ONEHEADER NOPRINT file=../1000par.tab','ONEHEADER NOPRINT file= 1000par.tab','ONEHEADER NOPRINT FILE=../1000.TAB','ONEHEADER NOPRINT FILE=~/1000.TAB','ONEHEADER NOPRINT FILE=~/example.tab')fixFile(tab,2000)files <- c('1000.msf','1000.tab','./1000.tab','../1000.tab','$TABLE EVID FILE=1000.tab','$TABLE EVID FILE=1000par.tab','$MSFI 1000.msf')explicitPath(files)extractPath(msf)extractPath(tab)resolve('./file.ext',dir='project/pk')resolve('../file.ext',dir='project/pk/')scavenge('.tab',lines=c('text file.TAB','text file.csv'))ctlfile <- c('text file=../100.tab etc','text file=../100par.tab etc','text file=../100.msf etc')tabfile(ctlfile,dir='projectdir/100')parfile(ctlfile,dir='projectdir/100')msffile(ctlfile,dir='projectdir/100')

ftable2data.frame Convert ftable to data.frame

Description

Convert ftable to data.frame As Displayed

Usage

ftable2data.frame(x,...)

Arguments

x ftable... ignored

94 getCovs

Details

as.data.frame.ftable does indeed convert an ftable to data.frame, but it gives a stackedresult. Use this function to give something more like what is displayed at the prompt (suitable forpassing to latex).

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

ftable(mtcars[c("cyl", "vs", "am", "gear")])as.data.frame(ftable(mtcars[c("cyl", "vs", "am", "gear")]))ftable2data.frame(ftable(mtcars[c("cyl", "vs", "am", "gear")]))

getCovs Return Non-commented Non-duplicated Rows of a NONMEM DataSet

Description

Given a file and directory, retrieve the NONMEM source data set and limit to one row per subject.

Usage

getCovs(file, dir)

Arguments

file relative path to a data file

dir directory to which that path is relative

Details

The data file in a control stream is typically expressed relative to the control stream’s directory. Thistool resolves that reference and returns the file, modified to represent constant covariates (commentsstripped, first row per ID).

Value

data.frame

getCwres 95

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

getCwres Return the Conditional Weighted Residuals Pertinent to a Given Run

Description

Locates ‘cwtab1.deriv’ and calls compute.cwres. Then returns the CWRES column from ‘cwtab1’.

Usage

getCwres(directory)

Arguments

directory NONMEM run directory

Value

numeric

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

96 getdname

getdname Extract the Path and File from the DATA Block in the Control StreamAssociated with a Filename

Description

Extracts the data path from the control stream, e.g., for use with getCovs. Default method assumesa scalar character value and interprets it as a file name. It is an error if the file does not exist. Themain work is done by the control stream method.

Usage

## Default S3 method:getdname(x,...)## S3 method for class 'nmctl'getdname(x,...)

Arguments

x object for dispatch

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

getPars 97

getPars Return the Non-duplicated (ID) Rows Corresponding to the SpecifiedFilename

Description

Useful for retrieving parameters that are constant within subject.

Usage

getPars(file)

Arguments

file path for a file, typcally ‘*par.TAB’

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

getTabs Return the Observation Rows (EVID==0) Corresponding to the Spec-ified Filename

Description

Useful for returning the PK portion of NONMEM run output.

Usage

getTabs(file)

Arguments

file path for a file, typically ‘*.TAB’

98 glue

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

glue Paste Items with No Space

Description

The default separator for paste is a space. Pasting with an empty string as separator seems soubiquitous as to merit its own function. glue is just a wrapper for paste with an empty stringseparator.

Usage

glue(...,sep='',collapse=NULL)

Arguments

... one or more R objects, to be converted to character vectors.

sep a character string to separate the terms.

collapse an optional character string to separate the results.

Details

All arguments are passed unmodified to paste See the related help for detials.

Value

character

Author(s)

Tim Bergsma

groupnames 99

References

http://metrumrg.googlecode.com

See Also

• paste

Examples

glue('cross','road')

groupnames Construct a Single Vector of Group Names from Possibly Multiple In-dices to the Plotting Data Set

Description

Callers of PLOTR may wish to group on more than one index. This function combines those indicesinto text for a single index vector.

Usage

groupnames(data, grp, grpnames = NULL, run)

Arguments

data data.frame in which to find the groups

grp columns by which to group

grpnames optional substitute names

run run name

Value

factor

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

100 half.matrix

half.matrix Interconvert Between a Symmetric Matrix and a Triangular Matrix

Description

Given a symmetric matrix, half.matrix converts the corresponding lower (upper) triangular matrixto a vector in row- (column-) major order. The vector is named using the convention row.column(for the lower interpretation) and is classed as halfmatrix. The function as.matrix.halfmatrixconverts a halfmatrix-like vector to a symmetric matrix. The halfmatrix method for genericoffdiag selects just the off-diagonal elements from the (named) vector of the corresponding class.

Usage

## S3 method for class 'matrix'half(x,...)## S3 method for class 'halfmatrix'as.matrix(x,...)## S3 method for class 'halfmatrix'as.halfmatrix(x,...)## Default S3 method:as.halfmatrix(x,...)## S3 method for class 'halfmatrix'offdiag(x,...)## S3 method for class 'halfmatrix'print(x,...)

Arguments

x symmetric matrix (half) or halfmatrix equivalent (as.matrix)

... extra arguments, ignored

Details

It is an error if x is a matrix but not symmetric. If x is a vector of appropriate length it can beconverted to a symmetric matrix by specifying the method explicitly, even if x is not classed ashalfmatrix: as.matrix.halfmatrix(x). x can also be converted to halfmatrix explicitly, in whichcase as.matrix(x)) suffices.

Value

vector with as many elements as a triangular matrix corresponding to x (except as.matrix returnsmatrix)

Author(s)

Tim Bergsma

hash 101

References

http://metrumrg.googlecode.com

See Also

• ord.matrix

• isSymmetric.matrix

Examples

half(diag(3))as.matrix(half(diag(3)))as.matrix.halfmatrix(1:15)as.matrix(as.halfmatrix(1:15))as.halfmatrix(1:10)offdiag(as.halfmatrix(1:10))

hash Supply Comment Characters with Output

Description

Any expression that generates output can be wrapped in a call to hash. The usual output will bereturned, with a hash character at the start of each line.

Usage

hash(x,char='#')

Arguments

x an R expression

char text to prepend to each line

Details

This is useful for embedding the result of an expression in a script.

Value

used for side effects

Warning

Don’t “hash” an expression that directly or indirectly calls a function being debugged. The debugoutput will be ‘sunk’ to a connection. If you get in this situation, recover by typing sink(NULL)until output is restored.

102 helpAdminister

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• file

• sink

helpAdminister metrumrg: Administrative

Description

Tools for administrative tasks.

Details

metrumrg

I want to ....

• delete files and directories; log what was deleted to a text file

• embed R output in a script

• document acceptance of an R installation

• check whether your files are subversioned

• test whether Subversion thinks your files are text

• tell Subversion to treat your files as text

• create an FDA-style electronic appendix from a Subversioned directory

• locate path-variant versions of a file

• install local source packages in dependency order

• convert line endings to local format

• delete certain files from run directories

• read data files from a directory into a list

• report names as comma-delimited

• test whether data corresponds to some specification

helpBrowse 103

helpBrowse metrumrg: Extended Examples

Description

Browse scripts showing use of package tools.

Details

metrumrg

I want to ....

• assemble a data set | as.nm• run models, make run logs, run predictive checks, launch bootstraps | NONR• plot covariate effects | covplot• generate parameter tables | partab• simulate with parameter uncertainty | simpar• use wikimath markup | wikimath• make simple latex tables | tabular

Links above are paired: online | local. For local links, see metrumrgURL entries in the examplesections of the help file.

helpClasses metrumrg: Data Classes

Description

Classes for building feature-rich data.

Details

metrumrg > Data

I want to ....

• create and manipulate comment objects• create and manipulate flags• create and manipulate keyed data.frames• column comparisons for keyed data.frames• interconvert time units• join or subtract keyed data.frames• create and manipulate nm objects• create and manipulate data specification objects

104 helpList

helpDataFrame metrumrg: Working with Data Frames

Description

Tools for processing data.frames.

Details

metrumrg > Data

I want to ....

• move columns in a data frame

• rename selected columns

• format a data.frame as fixed-width

• add named elements to a data.frame or list

• find the static portion of a data frame

• diagnose and visualize static data relationships

• diagnose missingness

• show sorted unique rows

• add supplemental data to a CDISC data set

• document and enforce data set properties

helpList metrumrg: Defined Functions

Description

Exhaustive list of functions defined by metrumrg.

Details

metrumrg

• [.comment subset a comment

• [.conditioned subset a conditioned object

• [.digest subset a digest object

• [.flag subset a flag

• [.initList subset initList

• [.keyed subset a keyed data frame

• [.nmctl subset a control stream object

helpList 105

• [.timeline subset a timeline object

• [.uniKey subset a uniKey object

• [[.comment select element from a comment

• [[.flag select element from a flag

• [[.nmctl select element from a control stream object

• [[.timeline select element from a timeline object

• [[.uniKey select element from a uniKey object

• [<-.timepoint assign to a timepoint object

• %+% generic set union binary operator

• %&% generic set intersection binary operator

• %-% generic set difference binary operator

• %u% generic set union binary operator

• %n% generic set intersection binary operator

• %+%.default vector set union

• %&%.default vector set intersection

• %-%.default vector set difference

• %contains% test whether x contains y

• %crossed.on% test whether a is crossed on b

• %crosses% test whether a crosses b

• %matches% generic

• %matches%.character test whether data (file name) matches spec

• %matches%.data.frame test whether data.frame matches spec

• %matches%.keyed test whether keyed data.frame matches spec

• %matches%.spec test whether spec matches data

• %nested.in% test whether a is nested in b

• %nests% test whether a nests b

• $.init select init element

• $<-.init assign init element

• +.timeline add timepoints and durations

• -.timeline subtract timepoints and durations

• accept document the acceptance of an R installation

• acceptance display the acceptance documentation for an R installation

• acr calculate accumulation ratio

• addl.data.frame collapse dose records by means of ADDL notation

• addl.default calculate the ADDL data item (NONMEM) from explicit dose records

• addl calculate addl

• after test whether elements occur after some condition is TRUE

106 helpList

• aggregate.keyed aggregate a keyed data frame

• align.decimal align numeric column in latex table on the decimal

• and.keyed produce inner join of two keyed data frames

• as.best.data.frame coerce a data.frame to unambigous numeric or character columns

• as.best.default coerce a vector unambiguously to numeric or character

• as.best.digest coerce a digest to unambiguous numeric or character

• as.best generic

• as.character.comment convert comment to character

• as.character.flag convert flag to character

• as.character.init convert init to character

• as.character.initList convert initList to character

• as.character.nmctl convert nmctl to character

• as.character.timepoint convert timepoint to character

• as.character.uniKey convert uniKey to character

• as.chartime.numeric convert numeric to time

• as.chartime convert to time (generic, internal)

• as.comment.comment convert comment to comment

• as.comment.default convert default to comment

• as.comment convert to comment

• as.conditioned.digest convert a digest to conditioned

• as.conditioned.isolated convert isolated to conditioned

• as.conditioned.keyed convert keyed to conditioned

• as.conditioned split a data frame per levels of conditioning variables

• as.csv.filename.character convert character to csv.filename

• as.csv.filename convert to csv.filename

• as.data.frame.block convert a block of lines to data frame

• as.data.frame.comment convert comment to data frame

• as.data.frame.flag convert flag to data frame

• as.day.day coerce day to day

• as.day.hour coerce hour to day

• as.day.month coerce month to day

• as.day.duration coerce duration to day

• as.day.numeric coerce numeric to day

• as.day.week coerce week to day

• as.day.year coerce year to day

• as.day coerce to day

• as.digest.data.frame convert data.frame to digest

helpList 107

• as.digest.digest convert digest to digest

• as.digest.keyed convert keyed to digest

• as.digest.nm convert nm to digest

• as.digest resolve static components of an object hierarchy

• as.document.character convert tex fragments to latex document

• as.document.data.frame convert data.frame to latex document

• as.document convert to latex document

• as.file.runlog convert to convert runlog to file

• as.filename.character convert character to filename

• as.filename convert to filename

• as.flag.default convert default to flag

• as.flag.flag convert flag to flag

• as.flag convert to flag

• as.halfmatrix.default convert a vector to halfmatrix

• as.halfmatrix.halfmatrix preserve halfmatrix

• as.halfmatrix generic

• as.hour.day coerce day to hour

• as.hour.hour coerce hour to hour

• as.hour.minute coerce minute to hour

• as.hour.duration coerce duration to hour

• as.hour.numeric coerce numeric to hour

• as.hour.second coerce second to hour

• as.hour coerce to hour

• as.init.init convert init to init

• as.init.numeric convert numeric to init

• as.init convert to init

• as.initList.character convert character to initList

• as.initList.initList convert initList to initList

• as.initList.list convert list (of init) to initList

• as.initList.numeric convert numeric to initList

• as.initList convert to initList (generic)

• as.isolated.digest convert digest to isolated

• as.isolated.isolated convert isolated to isolated

• as.isolated.keyed convert keyed to isolated

• as.isolated split a data frame column-wise into members with only one non-key column

• as.keyed.data.frame convert data frame to keyed

• as.keyed.nm convert nm to isolated

108 helpList

• as.keyed convert to keyed

• as.list.nmctl convert nmctl to list

• as.matrix.halfmatrix convert a vector to a symmetric matrix

• as.mDate.character convert character to mDate

• as.mDate.Date convert Date to mDate

• as.mDate.dates convert dates (chron) to mDate

• as.mDate.mDate convert mDate to mDate

• as.mDate.numeric convert numeric to mDate

• as.mDate.sasdate convert SAS date to mDate

• as.mDate convert to mDate

• as.mDateTime.character convert character to mDateTime

• as.mDateTime.chron convert chron to mDateTime

• as.mDateTime.mDate convert mDate to mDateTime

• as.mDateTime.mDateTime convert mDateTime to mDateTime

• as.mDateTime.numeric convert numeric to mDateTime

• as.mDateTime.POSIXct convert POSIXct to mDateTime

• as.mDateTime.POSIXlt convert POSIXlt to mDateTime

• as.mDateTime convert to mDateTime

• as.minute.hour coerce hour to minute

• as.minute.minute coerce minute to minute

• as.minute.duration coerce duration to minute

• as.minute.numeric coerce numeric to minute

• as.minute.second coerce second to minute

• as.minute coerce to minute

• as.month.day coerce day to month

• as.month.month coerce month to month

• as.month.duration coerce duration to month

• as.month.numeric coerce numeric to month

• as.month coerce to month

• as.moot convert to moot

• as.motif.digest create motif for digest

• as.motif.keyed create motif for keyed

• as.motif.motif create motif from motif

• as.motif.nm create motif for nm

• as.motif create default motif for various objects

• as.mTime.character convert character to mTime

• as.mTime.mTime convert mTime to mTime

helpList 109

• as.mTime.numeric convert numeric to mTime

• as.mTime.times convert times (chron) to mTime

• as.mTime convert to mTime

• as.nm.data.frame convert data frame to nm

• as.nm convert to nm (NMTRAN-ready NONMEM data set)

• as.nmctl.character convert character to nmctl

• as.nmctl convert to nmctl

• as.numeric.chartime convert chartime to numeric

• as.pdf.character convert tex fragments to pdf

• as.pdf.data.frame convert data.frame to pdf

• as.pdf.document convert latex document to pdf

• as.pdf convert to pdf

• as.pxml.ext convert a param file to XML

• as.rigged convert to rigged

• as.roles.digest create roles for digest

• as.roles.keyed create roles for keyed

• as.roles create default roles for parts of objects

• as.runlog.file convert file to runlog

• as.runlog.unilog convert unilog to runlog

• as.second.day coerce day to second

• as.second.hour coerce hour to second

• as.second.minute coerce minute to second

• as.second.duration coerce duration to second

• as.second.numeric coerce numeric to second

• as.second.second coerce second to second

• as.second coerce to second (time unit)

• as.spec generic

• as.spec.data.frame convert data.frame to spec

• as.spec.character convert file name to spec

• as.tabular convert to a latex tabular environment

• as.unilog.lst convert nonmem output (.lst) to unilog

• as.unilog.pxml convert nonmem output (.ext) to unilog

• as.unilog.run convert run to unilog

• as.unilog.runlog convert runlog to unilog

• as.week.day coerce day to week

• as.vector.keyed coerce keyed to vector

• as.vector.spec coerce spec to vector

110 helpList

• as.vector.uniKey coerce uniKey to vector

• as.week.duration coerce duration to week

• as.week.numeric coerce numeric to week

• as.week.week coerce week to week

• as.week coerce to week

• as.xml.character convert character to XML

• as.xml.data.frame convert data.frame to XML

• as.xml.default convert arbitrary object to XML

• as.xml convert object to XML

• as.year.day coerce day to year

• as.year.numeric coerce numeric to year

• as.year.year coerce year to year

• as.year coerce to year

• at test whether elements occur where some condition is TRUE

• attribute encode an attribute for an XML open tag

• auc calculate area under the curve

• AUC calculate the area under the curve for each subject over the time interval for dv using thetrapezoidal rule

• aug add named elements to an object

• autolog.pl prepare command lines for autolog.pl.

• backtrans backtransform cols in x, returning x

• badAmt.nm AMT is NA where EVID is 1

• badAmt generic

• badDv.nm DV is NA where EVID is 0

• badDv generic

• badII.nm II is greater than 0 where ADDL is NA or 0 (unless SS > 0)

• badII generic

• bakfor impute NAs using last observation carried forward after next observation carried back-ward

• before test whether elements occur before some condition is TRUE

• bin calculate bin limits for x and place each value in a bin, returning the number of values ineach bin

• bmi calculate body mass index

• bounds calculate normal quantiles at bounding probabilities

• bracket create an XML tag

• breaks calculate breaks between grouped elements

• bsa calculate body surface area

• bundleRead read filtered directory contents into a list

helpList 111

• c.comment combine comment

• c.flag combine flag

• c.timeline combine timeline

• c.uniKey combine uniKey

• cast,keyed-method cast a keyed data.frame, restoring key and output classes

• cavg calculate average concentration

• check.subjects check for missing data, numeric data, ranges, etc.

• clear drop regular patterns from a character vector

• CLNR delete files and directories and log what was deleted to a text file in the project

• closers set closing positions for wikmath nests

• cmax calculate maximum steady-state concentration

• cmin calculate minimum steady-state concentration

• codes generic

• codes.default extract codes from an encoded vector

• codes.spec extract codes from a spec guide

• colname<- change identified column names

• command generate a latex command

• combinations show sorted unique rows

• compileflag calculate compiler flag for qsub

• compiler extract compiler specification from configuration file

• compute.cwres compute conditional weighted residuals

• config calculate path to configuration file

• constant.default test whether values of x are contant within an index

• constant generic

• contains test a character vector for occurences of a pattern

• convertLines convert line endings

• covariatePlots create diagnostic plots for covariates

• crcl calculate creatinine clearance

• crosses test whether a crosses b

• css calculate steady-state concentration

• ctl2xml isolate xml comments from a control stream

• cvLognormal calculate coefficient of variation for log-normal data

• cvNormal calculate coefficient of variation for normal data

• cwresPlots create conditional weighted residual diagnostic plots

• dataFormat combine NONMEM predictions, parameter estimates, and covariates into a stan-dard format

• dataSynthesis build a standard plotting data set for a given NONR run

112 helpList

• decodes generic

• decodes.default extract decodes from an encoded vector

• decodes.spec extract decodes from a spec guide

• deranged.data.frame instantiate records implied by range data

• deranged.keyed instantiate records implied by range data

• deranged generic

• diagnosticPlots create standard diagnostic plots

• digest alias for as.digest

• distance calculate element positions relative to the nth TRUE element positions (usually, withinlevels of an index)

• divide.keyed for keyed data frames, rows in x that have matching keys in y

• dupKeys.default give a logical index to duplicated rows of a keyed data frame, AND the rowsof which they are duplicates

• dupKeys.nm default behavior, after stripping comments

• dupKeys generic

• dynamic.data.frame return the dynamic portion of a data frame

• dynamic.keyed return the dynamic portion of a keyed data frame

• dynamic generic

• electronicAppendix create an FDA-style electronic appendix from a subversioned directory

• encode generic

• encode.list encode levels and labels in simple strings

• encode.character encode levels and labels in simple strings

• encode.default encode levels and labels in simple strings

• encoded generic

• encoded.default test whether a vector is encoded

• encoded.spec test whether the guide column of a spec is encoded

• episcript run a script in an environment that defines the passed arguments

• explicitPath add separators to control stream paths that have none

• extfile extract arbitrary file specification from a control stream

• extract extract numbered parenthetical substrings of regular expressions

• extractPath isolate file path from surrounding text (MSF, TAB files).

• f alias for as.flag

• falseAmt.nm AMT defined where EVID is not 1

• falseAmt generic

• falseDv.nm DV is defined where EVID is not 0

• falseDv generic

• filename generate standard file name (internal)

• findNonmemCommand find available NONMEM executables

helpList 113

• first repeat, for each element, the first element where a condition is TRUE (usually, within levelsof an index)

• fixed.init find out if an init is fixed

• fixed.initList find out if elements of an initList are fixed

• fixed find out if something is fixed (generic)

• fixed<-.init set the value of ’fixed’ for an init

• fixed<-.initList set the values of ’fixed’ for elements of an initList

• fixed<- set the value of ’fixed’

• fixedwidth.data.frame convert a data.frame to fixed-width format

• fixedwidth convert to fixed-width format

• fixFile rewrite run name in control stream file specifications

• fixProblem rewrite run name in control stream PROBLEM statement

• follow follow progress of NONMEM runs

• forbak impute NAs using last observation carried forward and then next observation carriedbackward

• format.comment format comment

• format.flag format flag

• format.init format init

• format.initList format initList

• format.legacy pretty-print legacy information (conditioned objects)

• format.mDate format mDate

• format.mDateTime format mDateTime

• format.mTime format mTime

• format.nmctl format nmctl

• format.duration format duration

• format.uniKey format uniKey

• ftable2data.frame convert ftable to data.frame as displayed

• getCovs return non-commented non-duplicated rows of a NONMEM data set (internal)

• getCwres return the conditional weighted residuals pertinent to a given run (internal, expectscwtab1.deriv)

• getdname extract the path and file from the DATA block in the control stream associated withfilename (internal)

• getPars return the non-duplicated (ID) rows corresponding to the specified filename (internal)

• getTabs return the observation rows (EVID==0) corresponding to the specified filename (in-ternal)

• glue paste with no separator

• groupnames construct a single vector of group names from possibly multiple indices to theplotting data set (internal)

• guidetext generic

114 helpList

• guidetext.spec extract guide text from a spec

• half.matrix vectorize the lower triangular portion of a symmetric matrix

• half generic

• hash prepend a character to each line of output

• head.digest show head of each table in a digest

• hidden.data.frame show commented rows of a data frame

• hidden generic

• hide.data.frame comment out the specified rows of a data frame, appending a flag that suggeststhe reason

• hide generic

• ibw calculate ideal body weight

• ignored check which rows of an input data set were ignored by NONMEM

• ind.cwres compute conditional weighted residuals (internal)

• index.conditioned index a conditioned object

• index.digest index a digest

• index.isolated index an isolated object

• index.keyed index a keyed data frame

• index.nm index an nm object

• index create an index plot

• inner.data.frame reduce columns to inner quantiles by imputing NA

• inner generic

• is.alpha test whether text is letters-only

• is.cwres.readable.file compute conditional weighted residuals (internal)

• is.defined test whether elements are defined

• is.diagonal test whether parameter label represents matrix diagonal element

• is.fixed detect thetas in parameter labels

• is.iiv detect omegas in parameter labels

• is.latex.token test whether text is valid latex command or environment

• is.offdiagonal test whether parameter label represents matrix offdiagonal element

• is.one.nonalpha test whether text is singular non-letter

• is.random detect omegas and sigmas in parameter labels

• is.residual detect sigmas in parameter labels

• is.square.matrix test whether a matrix is square

• is.square generic

• isSubversioned check if files are subversioned

• isSubversionedFile check if one file is subversioned

• iterations retrieve iteration statistics from NONMEM output file

helpList 115

• justUnits extract units from wikimath

• ke calculate elimination constant

• key return the key of a keyed data frame

• key<- assign a key

• labels.spec extract labels from a spec

• last repeat, for each element, the last element where a condition is TRUE (usually, within levelsof an index)

• latest identify the latest of each set of variants

• latex.args format latex arguments

• latex.options format latex options

• lbm calculate lean body mass

• left.keyed produce left join of two keyed data frames

• legacy extract legacy from a conditioned object

• legacy<- assign legacy for a conditioned object

• lhs extract left-hand side of wikimath

• locf impute NA using last observation carried forward

• lookup.one translate among parameter attributes (scalar)

• lookup translate among parameter attributes (vector)

• lower calculate normal quantiles at lower probability of interval

• ltable.data.frame convert a data.frame to a latex table

• ltable convert to a latex table

• lyse.data.frame return the static and dynamic portions of a data frame

• lyse.keyed return the static and dynamic portions of a keyed data frame

• lyse generic

• makePreamble construct a preamble for a latex document

• map map one set of values to another

• maxChar return the number of printed characters for the widest element of x

• melt.keyed melt keyed data frames, restoring key

• merge.keyed merge keyed data frames, preserving attributes

• metaMerge.character recursively merge based on a vector of file names

• metaMerge.default merge two groomed objects

• metaMerge.list recursively merge elements of a list

• metaMerge generic

• metaSub.character systematically substitute elements in a character vector

• metaSub.filename systematically substitute elements in a text file

• metaSub generic

• metrumrgURL view a file in the metrumrg package

116 helpList

• minus.keyed drop rows in x that have matching rows in y

• minus.moot drop moot rows

• moot.nm identify moot rows (rows not influencing NONMEM estimates)

• moot generic

• monotonic generic

• monotonic.default check whether the values in a vector are monotonic

• nondecreasing generic

• nondecreasing.default check whether the values in a vector are nondecreasing

• nonincreasinggeneric

• nonincreasing.default check whether the values in a vector are nonincreasing

• motif alias for as.motif

• msffile extract msffile specification from a control stream

• naInContext display rows of data with missing values, as well as other rows with the same key

• naKeys.default detect rows for which one or more key fields is NA

• naKeys.nm default behavior, after stripping comments

• naKeys generic

• name<- change identified object names

• nasum diagnose missingness

• ncomma report names as comma-delimited

• nest nest an XML fragment in a parent element

• nix identify Unix-like platforms (internal)

• nm.pl prepare command lines for nm.pl

• nm give a zero-row data frame with suitable columns and column classes; i.e. a template forNMTRAN data sets

• nmPlots a list of functions that plot nm objects

• nmVersion extract NONMEM version specification from configuration file

• nocb impute NA with next observation carried backward

• NONR run NONMEM and create diagnostic plots

• noPk.nm rows where EVID is never 0 within SUBJ

• noPk generic

• nospace drop spaces from text

• not.keyed keyed data frame rows that have problematic keys (NA, dups)

• noUnits drop units from wikimath

• nth repeat, for each element, the nth element where a condition is TRUE (usually, within levelsof an index)

• nxt calculate the next element for each element of x

• offdiag.halfmatrix select just the off-diagonal elements of a halfmatrix

• offdiag generic

helpList 117

• omegacor convert omega covariance in NONMEM output to correlation matrix

• only repeat, for each element, the only element where a condition is TRUE (usually, withinlevels of an index)

• Ops.keyed use concise syntax to join data frames

• ord.halfmatrix compute the order of a half matrix

• ord.matrix compute the order of a symmetric matrix

• ord generic

• packageCheck load a package and run package-level examples

• padded pad a numeric with leading zeros

• panel.bar for each level, plot vertical (or horizontal) bars corresponding to x (y).

• panel.covplot plot distributions with respect to reference values; i.e. combine panel.cuts,panel.densitystrip, and panel.ref

• panel.cuts for each level, plot percent observations in each vertical category defined by cuts

• panel.densitystrip for each level, plot a filled polygon representing smoothed density of thedistribution

• panel.hist for each level, plot a histogram

• panel.ref plot a reference region in a stripplot

• panel.stratify handle strips (levels) of data one at a time

• parameter2wiki convert parameter labels to wikmath

• params list documented model parameters

• parens wrap text in parentheses

• parfile extract parfile specification from a control stream

• partab construct a model parameter table

• percent convert to percent

• plot.conditioned plot a conditioned object

• plot.digest plot a digest

• plot.isolated plot isolated

• plot.keyed plot keyed

• plot.nm generate standard plots for an nm object using nmPlots

• plotfilename make a name for a diagnostic plot file

• PLOTR create diagnostic plots for NONMEM runs

• plus.keyed produce and outer join of keyed data frames

• plus.rigged merge an nm object with a rigged data frame

• pool test for unique and shared elments among two vectors

• posmat coerce a matrix to be positive definite

• predoseDv.nm DV is defined before the first record within SUBJ where EVID is 1

• predoseDv generic

• prev calculate the previous element for each element of x

118 helpList

• print.comment print comment

• print.flag print flag

• print.halfmatrix print halfmatrix

• print.init print init

• print.initList print initList

• print.keyed.summary print keyed summary

• print.nm.summary print nm summary

• print.nmctl print nmctl

• print.duration print duration

• print.timepoint print timepoint

• print.uniKey print uniKey

• progress summarize progress of NONMEM runs

• purge.dir purge a directory (internal)

• purge.files purge files (internal)

• purgeRunDir delete certain files from run directories

• qstat invoke SGE qstat

• qsub prepare commandlines for qsub

• raised.keyed produce sequential left join of two keyed data frames

• read.cwres.data compute conditional weighted residuals (internal)

• read.nm read a csv file and try to transform to nm

• read.nmctl read a NONMEM control stream, converting to modifiable object

• read.spec read a spec

• reapply apply a function across cells of an indexed vector, giving an identically-indexed result

• rep.comment repeat comment

• rep.flag repeat flag

• rep.timeline repeat timeline

• rep.uniKey repeat uniKey

• resample.csv.filename create replicate data sets by stratified sampling with replacement, afterreading csv file

• resample.data.frame create replicate data sets by stratified sampling with replacement

• resample.filename create replicate data sets by stratified sampling with replacement, afterreading file

• resample generic

• resolve reinterpret relative file paths with respect to specified directory.

• rhs extract right-hand side of wikimath

• rig.nm generate extra rows, spaced across each subject’s timecourse, for obtaining model pre-dictions in NONMEM (EVID==2)

• rig generic

helpList 119

• rinvchisq generate inverse chi-square distribution

• riwish generate inverse Wishart distribution

• rlog generate a combined run log for multiple NONMEM runs

• roles alias for as.roles

• row2tabular convert a vector to a latex tabular row

• runCommand issue the system call that invokes NONMEM (internal)

• runhead determine whether each element is the start of a run

• runlog create a zero-row runlog

• runNonmem process a request for NONMEM invocation

• runstate determine the status of a run

• safe.call call a function, passing only those extra arguments that the function accepts

• safeQuote single-quote unquoted text that contains space

• scavenge find an expression in lines of text

• seq.timeline generate timeline sequence

• setCwres append conditional weighted residuals to an appropriate file

• shuffle move columns in a data frame

• sigmacor convert sigma covariance in NONMEM output to correlation matrix

• simblock generate deviates of the elements of a variance-covariance matrix

• simpar generate deviates of a set of model parameters for simulation

• snap coerce values to nearest of candidates

• sort.keyed sort a keyed data frame

• spaces create a string of spaces

• specification generic

• specification.comment pre-format a comment for specification

• specification.data.frame develop a draft specification for a data.frame

• specification.default pre-format a vector for specification

• specfile for a run and project, guess a path to a data specification file

• splom.conditioned scatterplot for conditioned

• splom.digest scatterplot for digest

• splom.keyed scatterplot for keyed

• sqrtm support compute.cwres

• stableMerge produce a left join, with strict error checking

• star replace asterisk in x with y (internal)

• static.data.frame return the static portion of a data frame

• static.keyed return the static portion of a keyed data frame

• static generic

• strain reduce x to those elements that occur in options (internal)

120 helpList

• Summary.timepoint group generic summary for objects of class ’timepoint’

• summary.hidden.data.frame summarize hidden rows of a data frame

• summary.keyed summarize a keyed data frame

• summary.nm summarize an nm object

• summary.spec summarize a spec object

• superset combine all NONMEM input with all output

• supp generic

• supp.data.frame supplement a CDISC data.frame

• supp.keyed supplement a CDISC keyed data.frame

• svnIsText check if subversioned files are text rather than binary

• svnMarkAsNonText tell Subversion to treat files as binary

• svnMarkAsText tell Subversion to treat files as text

• svnMimeType get the Subversion mime-type for files

• svnPropGet get a Subversion property for files

• svnPropGetFile get a Subversion property for one file

• svnPropSet set a subversion property on files

• svnPropSetFile set a Subversion property on a file

• svnSetMimeType set Subversion mime type on file

• synthesis sequentially left-join an arbitrary number of data frames, picking up novel columns(internal)

• tabfile extract tabfile specification from a control stream

• tabular.data.frame convert a data.frame to a latex tabular environment

• tabular convert to a latex tabular environment

• tabularformat generate a format string for a latex tabular environment

• tagvalue convert a list to a string of delimited tag-value pairs

• tex2pdf convert tex files to pdf

• text2decimal convert mixed text to decimal

• times.keyed column stable left join for keyed data frames

• titleCase convert mixed case to title case, strictly by default

• Tmax calculate the time associated with the maximum concentration for each subject

• tmax calculate the time of the maximum concentration

• Tmin calculate the time associated with the minimum concentration for each subject

• tos extract thetas, omegas, and sigmas from wikimath

• totitle convert mixed case to title case, not strictly by default

• transform.keyed transform a keyed data frame, preserving class

• tweak.init randomly adjust an initial parameter value

• tweak.initList randomly adjust a list of initial parameter values

helpList 121

• tweak.nmctl randomly adjust the initial fixed effect parameters in a control stream

• tweak randomly adjust a value

• uniKey.keyed create a single character vector from all the key columns

• uniKey generic

• unilog create a zero-row unilog

• unilogcor convert omega or sigma covariance in NONMEM output to correlation matrix

• unique.comment find unique elements of a comment vector

• unique.timepoint find unique elements of a timepoint vector

• unique.uniKey find unique elements of a uniKey vector

• unitDensity calculate univariate density with maximum equal to 1

• unitHist calculate univariate histogram architecture with maximum height equal to 1

• unsorted generic

• unsorted.keyed detect rows that would move on sort

• upper calculate normal quantiles at upper probability of interval

• variants locate variants of a file in distinctive subdirectories

• viewtex view (as pdfs) files that contain fragmentary tex code (e.g. tables)

• wiki2label convert wikimath to a label, e.g. CL/F

• wiki2latex convert wikimath to latex

• wiki2parameter convert wikimath to a parameter, e.g. THETA1

• wiki2plotmath convert wikimath to plotmath

• wikiparse parse wikimath

• wikitab extract wikimath specification from a control stream

• win identify Windows platforms (internal)

• wrap wrap text in a latex environment

• write.nm write an nm object to file

• write.nmctl write an nmctl object to file

• write.spec write a spec object to file

• xpath extract value of an xpath exrpession from an xml file

• xtfrm.comment produce a numeric vector that sorts in the same order as comment

• xtfrm.flag produce a numeric vector that sorts in the same order as flag

• xtfrm.timepoint produce a numeric vector that sorts in the same order as timepoint

• xtfrm.uniKey produce a character vector that sorts in the same order as uniKey

• xyplotExt plot the parameter search history for a NONMEM7 run

• zeroAmt.nm AMT is zero where EVID is 1

• zeroAmt generic

• zeroDv.nm DV is zero where EVID is zero

• zeroDv generic

122 helpModel

helpMatrix metrumrg: Working with Matrices

Description

Tools for processing matrices.

Details

metrumrg > Data

I want to ....

• interconvert between square matrices and triangular matrices

helpModel metrumrg: Modeling

Description

Tools for preparing, executing, and analyzing models.

Details

metrumrg

I want to ....

• assemble an analysis data set

• make multiple, systematic substitutions in text files, e.g., control streams

• convert NONMEM control streams to modifiable objects

• run NONMEM and create diagnostic plots

• determine the status of a run

• compute conditional weighted residuals in NONMEM 6, etc.

• visualize model results

• integrate model output with input

• adjust control stream initial estimates

• integrate model input with output

helpPharmacometric 123

helpPharmacometric metrumrg: Pharmacometrics

Description

Tools for investigating pharmacometric properties.

Details

metrumrg > Data

I want to ....

• calculate various clinical measurements, e.g., body size

• calculate one-compartment model properties

• summarize a table of subject data

• calculate Tmax

• calculate Tmin

• calculate AUC

helpPrepare metrumrg: Data Preparation

Description

Tools for preparing pharmacometric analysis data sets.

Details

metrumrg

I want to ....

• work with vectors

• work with data.frames

• work with matrices

• use classes specialized for data assembly

• investigate pharmacometric properties

• perform strategic data manipulations

• merge recursively

• diagnose and visualize static relationships

• document and enforce data set properties

124 helpReport

helpQuantify metrumrg: Statistics

Description

Tools for calculating statistics.

Details

metrumrg

I want to ....

• assign values in a vector to quantile bins

• coerce values to nearest of candidates

• calculate normal quantiles at limits of a probability interval

• calculate coefficient of variation for normal or log-normal data

• calculate percent

helpReport metrumrg: Reporting

Description

Tools for summarizing and reporting pharmacometric analyses.

Details

metrumrg

I want to ....

• identify documented parameter names

• lookup some other form of parameter names

• generate a combined run log from multiple NONMEM runs

• create a model parameter table

• convert parameter labels to wikimath

• convert wikimath to latex or plotmath

• manipulate wikimath elements

• list the iteration statistics in the NONMEM output

• convert the NONMEM output omega or sigma covariance matrix to correlations

• calculate coefficients of variation for normal or log-normal data

• calculate confidence intervals

helpSimulate 125

• analyze NONMEM-style parameter labels• reformat an ftable for printing with latex• convert a data.frame for printing with latex• render a data.frame to pdf format• render file-based tex fragments as pdf for informal viewing• extract value of an xpath expression from an xml file• create a draft specification for a data set

helpSimulate metrumrg: Simulation

Description

Tools for conducting simulations.

Details

metrumrg

I want to ....

• create replicate datasets by stratified sampling with replacement• convert a vectorized triangular matrix of random effects to a full matrix• create parameters for simulation with uncertainity• make multiple, systematic substitutions in text files, e.g., control streams• model a control stream for easy generation of variants• run NONMEM and create diagnostic plots• visualize simulation results

helpStrategic metrumrg: Strategic Data Manipulation

Description

Tools for strategic data manipulation.

Details

metrumrg > Data

I want to ....

• apply a function across cells of an indexed vector, giving an identically-indexed result• identify elements within cells that meet some instance of a condition• add keyed data to a data.frame safely

126 helpVisualize

helpVector metrumrg: Working with Vectors

Description

Tools for processing vectors.

Details

metrumrg > Data

I want to ....

• convert mixed text to decimal

• test a character vector for occurences of a pattern

• impute missing vector values

• check some properties of vectors

• create date, time, and date-time objects

• map one set of values to another

• coerce text to title case

• calculate the NONMEM ADDL data item from explicit dose records

• coerce a vector to either numeric or character

• interconvert time units

• test whether elements are defined

• test for unique and shared elements among two vectors

• binary operators for set relations

• check whether vector is nonincreasing, nondecreasing, and/or monotonic

• collapse levels and labels into simple strings

• extract numbered parenthetical substrings of regular expressions

helpVisualize metrumrg: Plotting

Description

Tools for creating plots.

ibw 127

Details

metrumrg

I want to ....

• create diagnostic plots for finished model runs• make forest plots of covariate effects• handle each level of a stripplot independently• plot nm objects• plot the parameter search history for a NONMEM7 run• make scatterplots and index plots for static members of a data set

ibw Calculate Various Clinical Indicators

Description

Calculate body mass index, body surface area, ideal body weight, lean body mass, or creatinineclearance using common equations.

Usage

bmi(wt, ht)bsa(wt, ht)lbm(wt, ht, male)ibw(ht, male, floor = FALSE)crcl(age, wt, male, scr)

Arguments

wt weight (actually, mass) in kilogramsht height in centimetersage age in yearsmale logical indicating sex: TRUE indicates malefloor if TRUE, “inches over 5 feet” is not allowed to be negative.scr serum creatinine in mg/dL

Details

Units of return values:

bmi kg/m2

bsa m2

lbm kgibw kgcrcl mL/min

128 index

Value

Numeric.

Author(s)

Tim Bergsma

References

bmi [http://www.halls.md/body-mass-index/bmirefs.htm]

bsa (BSA: Gehan & George variation) http://www.halls.md/body-surface-area/refs.htm

lbm http://www.halls.md/body-mass-index/leanbody.htm

ibw http://www.halls.md/ideal-weight/devine.htm

crcl http://en.wikipedia.org/wiki/Renal_function

Examples

bmi(70,160)bsa(70,160)lbm(70,160,TRUE)ibw(160,TRUE)crcl(35,70,TRUE,1.0)

index Visualize Static Data Relationships

Description

Cascading diagnostic plotting for data frames and data digests.

Usage

## S3 method for class 'digest'as.conditioned(x, ...)## S3 method for class 'isolated'as.conditioned(x, ...)## S3 method for class 'keyed'as.conditioned(x, roles = as.roles(x), ...)## S3 method for class 'digest'as.isolated(x, ...)## S3 method for class 'isolated'as.isolated(x, ...)## S3 method for class 'keyed'as.isolated(x, ...)## S3 method for class 'digest'as.motif(x, ...)

index 129

## S3 method for class 'keyed'as.motif(x, ...)## S3 method for class 'motif'as.motif(x, ...)## S3 method for class 'nm'as.motif(x, ...)## S3 method for class 'digest'as.roles(x, ...)## S3 method for class 'keyed'as.roles(x, motif = as.motif(x), ...)## S3 method for class 'conditioned'index(x, roles = as.roles(x), ...)## S3 method for class 'digest'index(x, motif = as.motif(x), roles = as.roles(x, motif = motif), ...)## S3 method for class 'isolated'index(x, roles = as.roles(x), ...)## S3 method for class 'keyed'index(x, roles = as.roles(x), ...)## S3 method for class 'nm'index(x, density = 20, ...)## S3 method for class 'conditioned'plot(x, roles = as.roles(x), ...)## S3 method for class 'digest'plot(x, motif = as.motif(x), roles = as.roles(x, motif = motif), ...)## S3 method for class 'isolated'plot(x, ...)## S3 method for class 'keyed'plot(x, roles = as.roles(x), ...)## S3 method for class 'conditioned'splom(x,data=NULL,roles = as.roles(x),main = "",xlab = "",pscales = 0,...)## S3 method for class 'digest'splom(x,data=NULL,motif = as.motif(x),roles = as.roles(x, motif = motif),main = "", xlab = "",pscales = 0,...)

130 index

## S3 method for class 'keyed'splom(x, data=NULL, roles = as.roles(x), ...)legacy(x, ...)legacy(x) <- value## S3 method for class 'legacy'format(x,...)

Arguments

x object of dispatch

roles named character vector with elements x, y, and z indicating columns to use foraxes or for grouping

motif a list with elements x, y, and z (optional), each of which are character vectors ofcolumn names in x, prioritizing alternative usage for plotting

density integer: how many levels of x to include per panel

main not passed to splom

data not passed to splom

xlab not passed to splom

pscales not passed to splom

value assigned to the legacy attribute of x

... extra arguments passed to other methods

Details

This is an experimental system for generating diagnostic plots. It was designed to work with theresult of digest, but can also work with data frames and keyed data frames, etc.

as.conditioned resolves a digest into a longer list of data frames (class conditioned), each ofwhich contain only single levels of key columns not mentioned in roles. as.isolated operates onconditioned or unconditioned keyed data frames, returning a list (class isolated) of data frameseach having exactly one non-key column. Default methods are defined for making index plots andscatterplot matrices of objects of class digest, conditioned, isolated, and keyed. The plot methodscurrently plot both.

For purposes of plotting and conditioning, it is necessary to specify the roles of the columns. Aroles object is a named vector with elements x, y, and z. Typically, y is a dependent variable, x isan independent variable, and z is a grouping variable (optional). y may be specified as ’.’, in whichcase it represents the non-key variable in context.

When plotting an entire digest all at once, it would be tedious to specify, in advance, roles for everyresulting view of the data. A motif is a general strategy for assigning roles. Unlike roles, it isa list. Like roles, it has elements x, y, and (optional) z. Each of these is a character vector ofcolumn names, typically consisting only of key columns and ’.’. Order is important: supportingfunctions assign x, y, and z in the order given, removing any assigned columns from considerationin later assignments. For example, time may be appropriate as x where available, and a subjectidentifier could be the alternative: motif=list(y=’.’,x=c(’time’,’id’)). Methods exist forcreating default motifs for a variety of objects. These are converted to roles in context.

The following are generic: as.motif, as.conditioned, index, as.roles, as.isolated.

inner.data.frame 131

motif and roles

are aliases for their as. counterparts.

Value

as.conditioned returns a list of objects each with class conditioned, keyed, data.frame.as.isolated returns a list of objects each with class isolated, conditioned, keyed, data.frame.as.motif and motif return an object of class motif with optional elements x, y, and z. as.rolesand roles return a named character vector, mapping column usage to roles x, y, and z. plot, splom,and index return lists of trellis objects, possibly with deep nesting. plot.digest gives a list witheach element having members splom and index. legacy returns named character; format.legacyreturns character. The assignment version of legacy requires named character and causes it to beappended to the legacy attribute of the object.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.keyed

• static

• digest

Examples

digest(Theoph,c('Subject','Time'))head(digest(Theoph,c('Subject','Time')))## Not run: index(as.keyed(Theoph,'Subject'))

inner.data.frame Limit Data to Inner Quantiles by Imputing NA.

Description

inner is generic. inner.data.frame imputes NA for cells within columns that represent extremequantiles. By default, the ‘inner’ 95 percent of each column is preserved.

132 inner.data.frame

Usage

## S3 method for class 'data.frame'inner(x,prob=0.95,tail=0.5*(1-prob),lo=tail,hi=prob+tail,include.lowest=TRUE,include.highest=TRUE,preserve=character(0),id.var=character(0),measure.var=setdiff(names(x),c(preserve,id.var)),na.rm=FALSE,...)

Arguments

x data.frame

prob the fraction of data to preserve

tail the fraction of data to ignore at each extreme

lo the probability below which data will be ignored

hi the probability above which data will be ignored

include.lowest whether to preserve values at probability equal to lo

include.highest

whether to preserve values at probability equal to hi

preserve vector of names for columns to preserve but ignore

id.var vector of names for columns that indicate data subsets

measure.var vector of names for columns to limit

na.rm passed to quantile

... passed to fun.aggregate

Details

prob and tail are not actually used internally, but serve only to calculate symmetric defaults forlo and hi. If the latter are supplied, the former are ignored. Tails need not be symmetric.

By default, all columns are classified as measure.var: an attempt will be made to limit such.Columns classified as preserve will simply be passed through to the result. Columns classified asid.var specify row subsets that are limited independently of eachother. See examples.

Value

a data frame with the same rows, columns, row order, and column order as x (except for droppedcolumns)

is.alpha 133

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• helpPrepare

Examples

x <- airquality[c(1:10,32:41),]xinner(x,id.var=c('Month','Day'),na.rm=TRUE)#identityinner(x,id.var='Month',preserve='Day',na.rm=TRUE)#quantiles within Monthinner(x,preserve=c('Month','Day'),na.rm=TRUE)#quantiles across all rowsinner(x,measure.var=c('Ozone','Solar.R','Wind','Temp'),na.rm=TRUE)# dropping Month, Dayinner(rock,prob=0.5)

is.alpha Test For Alphabetic Content

Description

Verify that each element contains only letters.

Usage

is.alpha(x, ...)

Arguments

x character

... ignored

Details

Verifies that each element in x contains only upper or lower case letters.

Value

logical

Author(s)

Tim Bergsma

134 is.defined

References

http://metrumrg.googlecode.com

See Also

• is.latex.token

Examples

is.alpha(c('aB','a2'))

is.defined Test Whether Values are Defined

Description

Test for data definition by negating the result of is.na.

Usage

is.defined(x)

Arguments

x object

Details

The function is.na is applied to the object, and the opposite of the result is returned. This yields amore intuitive syntax for certain tests.

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• is.na

is.diagonal 135

Examples

is.defined(letters)is.defined(Theoph)

is.diagonal Analyze Parameter Labels

Description

Analyze parameter labels of the form "THETA1" or "OMEGA2.3" or "SIGMA1.1". is.diagonaland is.offdiagonal decode the numeric x.x portion as indicating a region of a matrix (both rely onon.diagonal). is.fixed detects "THETA", is.iiv detects "OMEGA", and is.residual detects"SIGMA", reflecting conventional usage for population pk-pd. is.random detects all "OMEGA"and "SIGMA". All functions are case-insensitive.

Usage

on.diagonal(x)is.diagonal(x)is.offdiagonal(x)is.fixed(x)is.random(x)is.iiv(x)is.residual(x)

Arguments

x character

Details

Integer subscripts, as in "THETA1", are neither diagonal nor offdiagonal.

Value

logical

Note

x is coerced to numeric using text2decimal, so only the first two indices are considered. Forexample "omega1.2" gives the same result as "omega1.2.3".

Author(s)

Tim Bergsma

136 is.latex.token

References

http://metrumrg.googlecode.com

See Also

• offdiag

Examples

x <- c("THETA1","OMEGA2.1","SIGMA1.1")on.diagonal(x)is.diagonal(x)is.offdiagonal(x)is.fixed(x)is.random(x)is.iiv(x)is.residual(x)

is.latex.token Determine if String is Valid Latex Command or Environment

Description

Determine if string is valid latex command or environment name.

Usage

is.latex.token(x, ...)

Arguments

x character

... ignored

Details

Latex commands (and presumably, environment names) must consist entirely of upper or lower caseletters, or must be a single non-letter.

Value

logical

Author(s)

Tim Bergsma

is.one.nonalpha 137

References

http://metrumrg.googlecode.com

See Also

• is.alpha

• is.one.nonalpha

Examples

is.latex.token('2','word','word2')

is.one.nonalpha Check That Each Element is a Single Non-letter

Description

Verify that each element is just one non-letter.

Usage

is.one.nonalpha(x, ...)

Arguments

x character

... ignored

Details

Used to help identify proper latex command words.

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• is.latex.token

138 is.square.matrix

Examples

is.one.nonalpha(c(2,'b',23))

is.square.matrix Test Whether a Matrix is Square

Description

A matrix is square if its dimensions are equal.

Usage

## S3 method for class 'matrix'is.square(x, ...)

Arguments

x matrix

... extra arguments, ignored

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

ord.matrix, isSymmetric.matrix

Examples

is.square(diag(3))

isSubversioned 139

isSubversioned Check Whether Files Are Subversioned

Description

Check whether multiple files under Subversion control.

Usage

isSubversioned(x, ...)

Arguments

x character vector of file names

... ignored arguments.

Details

This is a vectorized version of isSubversionedFile.

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversionedFile

140 iterations

isSubversionedFile Check If Single file Is Subversioned

Description

Check if a single file is under Subversion control.

Usage

isSubversionedFile(file)

Arguments

file scalar character file name

Details

May return TRUE even if file does not exist.

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversioned

iterations Harvest Iteration Statistics from NONMEM Output and Convert fromCovariance to Correlation

Description

iterations excises the relevant portion of the output file, converting the text to parameter andgradient estimates.

Usage

iterations(x, ...)

iterations 141

Arguments

x character

... ignored

Details

The default result has intermediate dimensions as a compromise between very wide and very tall.

Value

data frame indicating parameter estimates and gradients by iteration

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• cov2cor

Examples

lst <- c('0ERROR SUBROUTINE CALLED WITH EVERY EVENT RECORD.','1',' ',' ',' #METH: First Order Conditional Estimation with Interaction',' MONITORING OF SEARCH:','','0ITERATION NO.: 0 OBJECTIVE VALUE: 3140.31595361523 NO. OF FUNC. EVALS.:10',' CUMULATIVE NO. OF FUNC. EVALS.: 10',' PARAMETER: 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1 1.0E-1',' 1.0E-1',' GRADIENT: 3.9E+0 -4.0E+2 7.1E+2 1.8E+1 -1.6E+2 6.9E-1 -8.4E+0 -7.5E+1 -2.1E+2 -6.6E+2',' -3.9E+1','0ITERATION NO.: 5 OBJECTIVE VALUE: 2506.10546953541 NO. OF FUNC. EVALS.:11',' CUMULATIVE NO. OF FUNC. EVALS.: 65',' PARAMETER: 6.2E-2 1.1E+0 -1.0E+0 -1.1E+0 4.2E-1 1.2E-1 2.7E-1 7.1E-1 3.0E-1 1.3E-1',' -1.2E-1',' GRADIENT: 8.6E+0 5.1E+1 2.9E+1 -3.5E+1 1.2E+1 2.2E+0 -2.5E+0 1.9E+1 -1.1E+1 -4.1E+0',' -1.3E+2','0ITERATION NO.: 10 OBJECTIVE VALUE: 2494.92785884531 NO. OF FUNC. EVALS.:12',' CUMULATIVE NO. OF FUNC. EVALS.: 123',' PARAMETER: -1.2E-1 9.9E-1 -1.1E+0 -1.2E+0 1.9E-1 1.6E-1 1.7E+0 5.0E-1 3.3E-1 1.2E-1',' -9.8E-2',' GRADIENT: 1.2E+1 3.1E+1 -3.1E+1 -1.5E+1 1.9E-1 5.3E+0 3.2E+0 4.0E-1 -3.6E+0 -3.3E+0',

142 justUnits

' -8.1E+1','0ITERATION NO.: 15 OBJECTIVE VALUE: 2487.99745856896 NO. OF FUNC. EVALS.:11',' CUMULATIVE NO. OF FUNC. EVALS.: 178',' PARAMETER: -9.0E-2 9.8E-1 -1.0E+0 -1.0E+0 1.8E-1 1.0E-1 1.3E+0 4.9E-1 2.8E-1 1.8E-1',' -4.7E-2',' GRADIENT: -5.0E-1 2.2E-1 -1.7E+0 7.8E-1 6.4E-1 -1.3E-1 -1.1E-1 1.7E-1 1.7E-1 1.4E+0',' 2.8E-1','0ITERATION NO.: 20 OBJECTIVE VALUE: 2487.98367110010 NO. OF FUNC. EVALS.:21',' CUMULATIVE NO. OF FUNC. EVALS.: 246',' PARAMETER: -8.8E-2 9.8E-1 -1.0E+0 -1.0E+0 1.7E-1 1.0E-1 1.3E+0 4.9E-1 2.8E-1 1.7E-1',' -4.7E-2',' GRADIENT: -5.8E-1 -1.1E+0 -4.6E+0 -4.7E-1 -2.2E-1 -1.2E-1 -2.9E-1 4.8E-2 1.5E-1 -5.1E-1',' -1.3E-1','0ITERATION NO.: 25 OBJECTIVE VALUE: 2487.88855559751 NO. OF FUNC. EVALS.:16',' CUMULATIVE NO. OF FUNC. EVALS.: 340',' PARAMETER: -8.8E-2 1.0E+0 -9.9E-1 -1.0E+0 1.7E-1 9.7E-2 1.4E+0 4.8E-1 2.7E-1 1.8E-1',' -4.6E-2',' GRADIENT: -9.4E-3 8.1E-3 4.5E-2 -1.9E-2 -7.8E-4 -1.0E-3 -7.2E-4 3.5E-3 -2.6E-3 1.1E-2',' 9.0E-3',' Elapsed estimation time in seconds: 3.11',' ',' #TERM:','0MINIMIZATION SUCCESSFUL',' NO. OF FUNCTION EVALUATIONS USED: 340',' NO. OF SIG. DIGITS IN FINAL EST.: 3.2','',' ETABAR IS THE ARITHMETIC MEAN OF THE ETA-ESTIMATES,',' AND THE P-VALUE IS GIVEN FOR THE NULL HYPOTHESIS THAT THE TRUE MEAN IS 0.','',' ETABAR: 2.3E-3 8.5E-4 6.8E-4',' SE: 6.8E-2 4.6E-2 4.7E-2','',' P VAL.: 9.7E-1 9.8E-1 9.8E-1',' ',' ETAshrink(%): 7.3E-1 1.6E+1 6.5E+0',' EPSshrink(%): 8.8E+0',' ',' #TERE:',' Elapsed covariance time in seconds: 4.27','1')iterations <- iterations(lst)iterationsit.dat <- melt(iterations,measure.var=names(iterations)[contains('X',names(iterations))])xyplot(value~iteration|variable,it.dat[it.dat$course=='parameter',],type='l',ylab='scaled parameter',as.table=TRUE,scales=list(y=list(relation='free')))xyplot(value~iteration|variable,it.dat[it.dat$course=='gradient',] ,type='l',ylab='gradient',as.table=TRUE,scales=list(y=list(relation='free')))

justUnits Extract Substring of Wiki Math

justUnits 143

Description

Extract logical portions of text formatted with wikimath conventions.

Usage

justUnits(x, ...)noUnits(x, ...)lhs(x, ...)rhs(x, ...)nospace(x, ...)tos(x, ...)

Arguments

x character; typically wikimath... ignoreded, or passed to sub for lhs and rhs

Details

justUnits extracts the contents of the first parenthetical inclusion. noUnits drops the first paren-thetical inclusion. nospace removes all spaces. tos extracts the first occurrence of x_num, wherex is ’theta’, ’omega’, or ’sigma’ (case insensitive) and num is an unsigned decimal (1, 2.1, etc.).

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• wikiparse

• wiki2plotmath

• wiki2latex

Examples

wiki <- "CL/F (L) ~ theta_1 * (WT/70)^theta_2"justUnits(wiki)noUnits(wiki)lhs(wiki)rhs(wiki)nospace(noUnits(lhs(wiki)))tos(wiki)

144 keyed-class

keyed-class Class "keyed"

Description

This class is a data frame with an associated key. The key is the names of the columns that identifyobjects in the table. Other columns presumably indicate attibutes of those objects. The validity ofthe key is not enforced unless necessary. The class is implemented as S3, and is promoted to S4 totake advantage of S4 generic mechanisms.

Objects from the Class

A virtual Class: No objects may be created from it.

Slots

.Data: Object of class "list"

names: Object of class "character"

row.names: Object of class "data.frameRowLabels"

.S3Class: Object of class "character"

Extends

Class "data.frame", directly. Class "list", by class "data.frame", distance 2. Class "oldClass",by class "data.frame", distance 2. Class "vector", by class "data.frame", distance 3.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.keyed

Examples

showClass("keyed")

latest 145

latest Identify the Latest Variants of Each File as Distinguished by EnclosingSubdirectories

Description

For each of a set of file variants as returned by variants, identify that file whose enclosing directorysorts last (i.e., latest if a timestamp).

Usage

latest(x)

Arguments

x character vector of file paths of the form ‘path/file/var1/file’

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• variants

Examples

latest(c('path/file/var2/file','path/file/var1/file'))

146 latex.args

latex.args Format Latex Command Arguments

Description

Format latex command arguments.

Usage

latex.args(x, ...)

Arguments

x list or vector

... ignored

Details

Each element wrapped in curly braces; elements are strung together.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• wrap

• command

Examples

latex.args(c('arg1','arg2'))

latex.options 147

latex.options Format Latex Command Options

Description

Format latex command options.

Usage

latex.options(x, ...)

Arguments

x list or vector

... ignored

Details

Elements are strung in a comma separated list, optionally with name= syntax. List is enclosed insquare brackets.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• wrap

• command

• tagvalue

Examples

latex.options(c(ht=2,width=3))

148 locf

locf Impute Missing Vector Values

Description

Impute NA values using other values in the vector.

Usage

locf(x)forbak(x)bakfor(x)nocb(x)

Arguments

x A vector with some missing values and some non-missing values.

Details

locf implements “last observation carried forward”: NA’s are imputed with the most recent non-NAvalue. nocb is the complement: “next observation carried backward”: NA’s are imputed with thenext non-NA value. forbak first executes locf, then nocb, so that even leading NAs are imputed. Ifeven one non-NA value is present, forbak should not return any NAs. bakfor does the reverse.

Value

A vector of the same class as x.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

locf(c(NA,1,2,NA,NA,3,NA,4,NA))nocb(c(NA,1,2,NA,NA,3,NA,4,NA))forbak(c(NA,1,2,NA,NA,3,NA,4,NA))

lookup 149

lookup Lookup Alternate Versions of Parameter Codes

Description

Parameter names have differing canonical forms depending on whether they are being used in aNONMEM control stream, an R plot, a latex table, etc. The functions described here form a gener-alized interface for interconverting these forms, given some xml-encoded data in a file, typically acontrol stream.

Usage

lookup( x, within, by = 'name', as = NULL, type = 'parameter', ...)lookup.one(x, within, by = 'name', as = NULL, type = 'parameter', ...)ctl2xml( x, ...)clear( x, drop = NULL, ...)

Arguments

x a vector of parameter names (character)

within an XML ‘document’ containing parameter elements (character)

by the parameter attribute by which to interpret x

as the parameter attribute as which to re-present x. If null, the text value of theelement (if any) is returned.

type the element type to seek in ‘within’

... passed to other functions

drop for clear: a vector of patterns to be replaced sequentially with ’’ (nothing)

Details

clear helps to isolate XML fragments from a text file. ctl2xml puts it to use, assuming the frag-ments occur after the control stream comment character: it drops material up to and including thecomment character, and then drops everything up to the first ’<’. It is expected that a <parameter>declaration follows.

lookup.one is the engine that researches elements of x, one at a time.

lookup is the typical user interface to this system. Try this.

• In your control stream, create parameter comments for each element, e.g. TVCL = THETA(1) ; <parameter name=’THETA1’ lattice=’TH1’ latex=’\theta_1’>typical value of clearance</parameter>

• In your script, use readLines to acquire your control stream as a character vector.

• Use ctl2xml to convert that vector to XML.

• Pass the converted vector to lookup as the argument within.

150 ltable.data.frame

Value

All these functions return character. lookup returns a vector of names corresponding to x, buthaving some other form (representing some other attribute).

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

codes <- c('; etc <parameter name="THETA1" lattice="TH1" latex="\\Theta_1">wt. on cl.</parameter>','and some other stuff',';<parameter name="OMEGA1" lattice="OM1" latex="\\Omega_1">iiv on vol.</parameter>','with maybe a < sign',';<parameter name="SIGMA1" lattice="SG1" latex="\\Sigma_1">additive error</parameter>')codesdoc <- ctl2xml(codes)lookup(c('TH1','SG1','OM1',NA),within=doc,by='lattice')lookup(c('THETA1','SIGMA1','OMEGA1'),within=doc,as='lattice')

ltable.data.frame Convert a Data Frame to a Latex Table

Description

Convert data.frame to latex table.

Usage

## S3 method for class 'data.frame'ltable(x,caption = NULL,cap = caption,cap.top = TRUE,label = NULL,options = "!htpb",environments = "center",source = NULL,file = NULL,source.label='source: ',file.label='file: ',

ltable.data.frame 151

basefile=FALSE,...)

Arguments

x data.frame

caption full version of the caption

cap short version of the caption, for list of tables

cap.top Should caption be placed at the top, instead of bottom?

label optional label

options options for latex table environment

environments extra environments to nest between ‘table’ and ‘tabular’.

source optional source attribution

file optional file name

source.label optional text to preceed source if specified

file.label optional text to preceed file if specified

basefile if TRUE, strip path from file for display purposes

... passed to tabular

Details

Converts data.frame to tabular, then wraps it in specified environments, then wraps result in a latextable environment. Result is returned visibly, or if file is specified it is printed to file and returnedinvisibly.

If source and source.label are defined, they will be printed in a tiny font immediately underthe table (bound to the tabular element). If file and file.label are defined as well, they will beprinted (tiny) under source. Set source.label to NULL to suppress embedding of source; set toempty string to suppress source label. Set file.label to NULL to suppress embedding of file;set to empty string to suppress file label. Note that file controls file destination, whether or notrepresented in the result.

ltable is generic. You can write methods for other classes. as.ltable is an alias for ltable.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

152 map

See Also

• tabular.data.frame

Examples

ltable(head(Theoph))

map Map One Set of Values to Another

Description

Systematically substitute specific values from one set using corresponding values from another set.

Usage

map(x, from, to, strict=TRUE, ...)

Arguments

x vector

from vector (elements usually unique)

to vector with same length as from

strict whether to set unmapped values to NA (default)

... ignored

Details

Occasionally one wants to recode a set of categories using some other idiom. factor supportsrecoding by creative use of the arguments levels and labels. However, the result is a factor,and may need more transformation. Furthermore, factor allows one-to-one reclassification butnot many-to-one reclassification (repeated levels is not supported; i.e., it is not directly possible tocollapse two levels to a single replacement code).

Here, from is the discrete set of values we expect in x, and to is the element-wise correspondingvalues with which we wish to re-present elements in x. Values in x not found in from will benormally represented as NA (which is itself a legitimate value for to). However, if strict=FALSE,map tries to preserve un-mapped values.

It is an error if from and to have different lengths.

Value

vector of same class as to and same length as x

Author(s)

Tim Bergsma

matches 153

References

http://metrumrg.googlecode.com

See Also

• match

Examples

map(c('white','Asian','Indian'),from=c('white','White','black','Black','asian','Asian'),to= c( 1, 1, 2, 2, 3, 3 ))

matches Test the Correspondence between a Table and a Specification

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), andcoerces y using as.spec. The latter in turn should be a single file name for a spec, if character. Themethod for spec treats y as the data frame. The real work is done by the keyed method.

Usage

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

154 matches

Details

matches returns TRUE if no exceptions are detected. It checks the following, and issues appropriatemessages 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 decimalplaces.

• 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. – thenall 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 re-quirements.

Value

scalar logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.spec

• specfile

• specification

• codes

• encode

Examples

test <- Theophnames(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))))))

)

melt.keyed 155

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)

spec <- specification(test)summary(spec)write.nm(test, 'test.csv')write.spec(spec,'test.spec')

labels(as.spec('test.spec'))codes(as.spec('test.spec'))decodes(as.spec('test.spec'))guidetext(as.spec('test.spec'))

test %matches% spectest %matches% 'test.spec''test.csv' %matches% spec'test.csv' %matches% 'test.spec'spec %matches% testspec %matches% 'test.csv'unlink('test.csv')unlink('test.spec')

melt.keyed Melt a Keyed Data Frame

Description

Melt an object with class c(’keyed’,’data.frame’). See also melt.data.frame.

Usage

## S3 method for class 'keyed'melt(data,id.vars=key(data),measure.vars,variable_name = "variable",na.rm = FALSE,...

)

Arguments

data passed to melt

156 melt.keyed

id.vars passed to melt

measure.vars passed to melt

variable_name passed to melt

na.rm passed to melt

... passed to melt

Details

The package reshape declares the S3 generic melt, and declares a data.frame method for it. Thekeyed method is similar, but returns a keyed object. The key consists of all columns except value.

Value

An object with class c(’keyed’,’data.frame’)

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• cast,keyed-method

Examples

time <- rep(2,8)start <- cumsum(time)start <- as.mTime(as.second(as.hour(start)))stop <- start + as.second(as.minute(30))x <- data.frame(

subj = rep(c('a','b'), each=4),period = 1:4,start=start,stop=stop

)x <- as.keyed(x, c('subj','period'))xsummary(x)y <- melt(x)ysummary(y)cast(y)

metaMerge 157

metaMerge Recursively Merge Multiple Tables

Description

Perform an n-way merge, given multiple objects or file names.

Usage

## S3 method for class 'list'metaMerge(x,all=TRUE,...)## S3 method for class 'character'metaMerge(x,import=read.table,all=TRUE,...)## Default S3 method:metaMerge(x,y,all=TRUE,...)## S3 method for class 'data.frame'metaMerge(x,y,all=TRUE,...)## S3 method for class 'NULL'metaMerge(x,y,all=TRUE,...)

Arguments

x a list of objects, e.g. data.frames, or a character vector of file namesy a second objectall passed to merge

import a function for reading files... passed to import

Details

If x is a character vector, it is presumed to be file names. An error is returned if any file does notexist. Otherwise, files are acquired using import (after a call to match.fun). The resulting list ofobjects is merged.

If x is an empty list, it is returned. If of length one, the first element is returned. Otherwise, thefirst element is merged with the second, and the result merged with the third (if present), and so on.Merges are full or outer merges; i.e. all=TRUE.

The default method simply calls merge and is present for methodological reasons.

Value

object like the elements of x, or given by import

Note

In most cases, merge is eventually called. Since merge is generic, what happens next depends onthe class of the arguments. For example, a merge method has been defined for class nm, which maygive unexpected results.

158 metaSub.character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• merge

Examples

#a nonsense examplehead(metaMerge(list(Theoph,BOD)))

metaSub.character Create Replicate Text files with Systematic Substitutions

Description

metaSub is generic. A method is defined for character; a convenience wrapper is provided forpassing names of text files to be read and then resampled.

metaSub collapses a character vector to one line of text. The vector is replicated as many timesas there are elements in names, with flexible substitution of text fragments. If out is supplied, thereplicates are saved as text files identified with names and a suffix.

metaSub.filename will process multiple filenames, if x is as long as names.

Usage

## S3 method for class 'character'as.filename(x, ...)## S3 method for class 'filename'metaSub(x, names, pattern=NULL, replacement=NULL, ...)## S3 method for class 'character'metaSub(x,names,pattern = NULL,replacement = NULL,out = NULL,suffix = '.txt',fixed = TRUE,...)

metaSub.character 159

Arguments

x scalar character, or (second form) filename(s). Multi-element character will becollapsed to one element, with newline as the separator.

names a list of (unique) names for resulting output elements. A vector of names willbe coerced to character and to list.

pattern a character vector of text fragments to replace, optionally encoded as regularexpressions (fixed==FALSE, See ?gsub, ?regex). Can also be a list. See details.

replacement A character vector of substitutions for patterns. The wildcard ‘*’ is availableto represent the corresponding value of names. Can also be a list with as manyelements as pattern (see details). Expressions are supported (see details).

out (path and) directory in which to write the resulting control streams

suffix file extension for filenames, if out is supplied

fixed passed to gsub: use FALSE if pattern contains regular expressions. Scalar, orsame length as pattern.

... extra arguments, available to expressions or passed to gsub

Details

Typical usages are

metaSub(x, names, ...)metaSub(as.filename(x), names, ...)

Replacement is performed by gsub, so an element of pattern will be replaced everywhere it occursin a line.

if pattern or replacement is a list, each element should be of length one, or as long as names. Inthe latter case, substitutions can be specific on a per-name basis. The wild card ‘*’ is still available.

It is necessary that pattern and replacement be of the same length, but it is not necessary thattheir corresponding elements have equal lengths. Thus, one can specify name-specific replacementsfor a single pattern, or a single replacement for name-specific patterns.

An expression can be specified for replacement itself, or one of its pattern-wise elements, or oneof the name-wise elements of a pattern-wise element. Expressions are evaluated in an environmentcontaining “name” (same meaning as ‘*’ above) and all other . . . arguments. This is useful if extraarguments have a dimension indexed, at least loosely, by names. The evaluated expression is treatedas character, and wildcard substitution is attempted. Use \* for a literal asterisk: in R: \\*.

NOTE: be very careful not to have trailing commas in your lists! An error results that is very hardto track. e.g. c(a,b,c,).

Value

an invisible named character vector. If out is supplied, elements are written as files with corre-sponding names.

Author(s)

Tim Bergsma

160 metaSub.character

References

http://metrumrg.googlecode.com

See Also

• gsub

• regex

Examples

ctl <- readLines(system.file('example/misc/8.ctl',package='metrumrg'))dir()e <- metaSub(ctl,names=1:3,pattern=c('PROBLEM 8','data8.csv','8.MSF'),replacement=c('PROBLEM *','*.csv','*.MSF'),out='.',suffix='.ctl')t <- metaSub(ctl,names=c('test1','test2'),pattern=c('PROBLEM 8','data8.csv','METH=0'),replacement=c('PROBLEM *','*.csv','METH=1'),)

t <- metaSub(ctl,names=c('test1','test2'),pattern=c('PROBLEM 8','data8.csv','METH=0'),replacement=list('PROBLEM *','*.csv',c('METH=1','METH=2')),out='.',suffix='.ctl')#just a file copy...

metrumrgURL 161

metaSub(as.filename('1.ctl'),names='4',out='.',suffix='.ctl')

#using a (nonsense) replacement expression...options <- data.frame(var=c(8,9),alt=c(10,11))a <- metaSub(ctl,names=rownames(options),pattern='9999',replacement=expression(options$var[rownames(options)==name]),options=options)cat(a[[2]])

#replacement expression in a 'mixed' list...b <- metaSub(ctl,names=rownames(options),pattern=list('PRINT=2','9999'),replacement=list('PRINT=3',expression(options$var[rownames(options)==name])),options=options)cat(b[[2]])

#replacement expressions on a per-name basisd <- metaSub(ctl,names=rownames(options),pattern='9999',replacement=list( #so that replacement is as long as patternlist( #with different options for each 'name'expression(options$var[rownames(options)==name]),expression(options$alt[rownames(options)==name]))),options=options)cat(d[[2]])

metrumrgURL View a metrumrg Package File

162 monotonic

Description

Open a file in the metrumrg package using a default viewer.

Usage

metrumrgURL(url, lib.loc = NULL, browser = getOption("browser"), encodeIfNeeded = FALSE)

Arguments

url a file path relative to the package root

lib.loc passed to system.file

browser passed to browseURL

encodeIfNeeded passed to browseURL

Details

Example files included in the metrumrg package can be difficult to find. This function combinessystem.file and browseURL to open the package-relative url in a viewer.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• browseURL

• system.file

Examples

## Not run: metrumrgURL('example/wikimath/wikimath.pdf')

monotonic Determine Whether a Vector is Monotonic

Description

If each successive value in a numeric vector is less-than-or-equal-to the previous, or if each suc-cessive value is greater-than-or-equal-to the previous, we understand the vector as a whole to bemonotonic. The functions nondecreasing and nonincreasing give element-wise diagnoses,showing positions at which the assertion holds (element 1 is always TRUE). Use strict=TRUEfor strictly less-than or greater-than logic.

monotonic 163

Usage

## Default S3 method:nondecreasing(x, strict=FALSE, ...)## Default S3 method:

nonincreasing(x, strict=FALSE, ...)## Default S3 method:

monotonic(x, strict=FALSE, ...)

Arguments

x vector

strict if FALSE, repeated values are tolerated. See examples.

... ignored

Value

logical. A single valueFor monotonic; A vector (same length as x) nondecreasing and nonincreasing.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• prev

Examples

x <- c(1,2,2,3,4)nondecreasing(x)nonincreasing(x)monotonic(x)monotonic(x,strict=TRUE)

164 naInContext

naInContext Display Missing Values in Context

Description

Display rows of data with missing values, as well as other rows with the same key.

Usage

naInContext(x, context, search)

Arguments

x data.frame.

context character vector of column names representing a key

search character vector of column names representing search fields.

Details

Often one wants to view not just records with missing values, but other related records as well,e.g. “view all the records for any subject with missing doses”. naInContext searches for NAs incolumns of x named by search. It then determines keys for these rows, using columns in x namedby context. Finally, it displays all rows with matching keys.

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

test <- Theophtest$conc[[5]] <- NAnaInContext(test, context='Subject', search='conc')

nasum 165

nasum Count Number of NA Values in List Items

Description

nasum Count the number of NA values in each element of a list-like object.

Usage

nasum(x,simplify=TRUE)

Arguments

x list of vector-like objects; e.g. a data frame

simplify logical: coerce to vector result if possible

Details

Arguments are passed to simplify, along with a function that sums instances of NA.

Value

numeric or list

Author(s)

Natalie Hsiang

References

http://metrumrg.googlecode.com

See Also

• is.na

Examples

nasum(Theoph)

166 ncomma

ncomma Report Names as Comma-delimited

Description

A convenience wrapper to report names as comma-delimited.

Usage

ncomma(x,...)

Arguments

x object

... passed to names()

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• names

Examples

ncomma(Theoph)

nest 167

nest Nest an XML Fragment in a Parent Element

Description

Create matching open and close tags and embed an XML fragement between them.

Usage

nest(x, tag, ...)

Arguments

x an XML fragment

tag an element name

... ignored

Details

Attributes are not supported.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• bracket

• as.xml.data.frame

• as.pxml.ext

Examples

nest('some xml',tag='content')

168 nm.pl

nix Identify Unix-like Platforms

Description

Tells whether the platform OS is of type ’unix’.

Usage

nix()

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• NONR

Examples

nix()

nm.pl Build Commands to Invoke NONMEM

Description

Format a set of commandlines, suitable for submission to a command shell, to operate the executablefor an NMQual-mediated NONMEM installation. nm.pl is the default for NONMEM 7.1.2 andearlier. autolog.pl is the default for NONMEM 7.2.0 and later.

nm.pl 169

Usage

nm.pl(command,ctlfile,outfile = NULL,perl = 'perl',checksum = TRUE,compile = TRUE,execute = TRUE,split = FALSE,...)autolog.pl(command,rdir,run,perl = "perl",compile = TRUE,execute = TRUE,split = FALSE,config = file.path(dirname(command),"log.xml"),mode = "run",...)

Arguments

command path for the installation-specific variant of ‘nm.pl’ctlfile path for a control streamoutfile path for outputperl how to invoke Perl on this systemchecksum whether to conduct checksumscompile whether to compile NONMEMexecute whether to execute the compiled NONMEMsplit whether to compile and execute as separate stepsrdir run directoryrun run nameconfig path to a configuration file (sensu NMQual 8)mode process mode... ignored

Details

If split is TRUE, two commands are returned, having the mode flags ‘c’ and ‘e’, respectively. nm.pldrops the ‘c’ or ‘e’ argument if split is FALSE and both compile and execute are TRUE. In theidentical case, autolog.pl passes ‘ce’.

170 nmPlots

autolog.pl returns a run directory and run name, rather than input and output file paths as innm.pl. autolog.pl does not support checksum. By default, autolog.pl expects a config filecalled ‘log.xml’ in the same directory as command; it also assumes the mode is ‘run’. See alsohttp://nmqual.googlecode.com.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runCommand

Examples

nm.pl('/nm6/test/nm6.pl','1.ctl')nm.pl('/nm6/test/nm6.pl','1.ctl','1.out',checksum=FALSE)nm.pl('/nm6/test/nm6.pl','1.ctl',execute=FALSE)nm.pl('/nm6/test/nm6.pl','1.ctl',compile=FALSE)nm.pl('/nm6/test/nm6.pl','1.ctl',split=TRUE)autolog.pl('/nm72/nmqual/autolog.pl','/home/ubuntu/test/3',3)

nmPlots An Extensible List of Diagnostic Plots for nm Objects

Description

Default diagnostics for plotting an nm object.

kinetics dose and concentration data

constantContinuous continuous variables that are constant within SUBJ

varyingContinuous continous variables that vary within SUBJ

constantCategorical categorical variables that are constant within SUBJ

varyingCategorical categorical variables that vary within SUBJ

Details

plot.nm preprocesses an nm dataset and passes it to a subset of nmPlots. Extra arguments can bepassed to plot.nm to exert fine control on the end results.

nmVersion 171

See Also

• plot.nm

nmVersion Extract the NONMEM Version from an NMQual Configuration File

Description

This function reads the configuration file and extracts the version number from the ’nonmem’ ele-ment.

Usage

nmVersion(config, ...)

Arguments

config path for a configuration file

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runNonmem

Examples

## Not run: nmVersion('../NONMEM/nm6osx1/test/config.xml'))

172 NONR

NONR Run NONMEM

Description

NONR executes, from R, a NONMEM run for which there exists a compatible (see note) controlstream. Supported platforms include MS Windows and Unix-like operating systems (Nix). Specialsupport is included for Sun Grid Engine with Nix. Defaults are currently chosen for NONMEM7.3. Generally, NONMEM needs to be installed using NMQual (http://nmqual.googlecode.com).See also autolog.pl. Execution on the Nix grid requires the installation of Sun Grid Engine v6.Following a successful NONMEM run NONR can call PLOTR to create diagnostic plots (pdf format)and/or run a user-written script.

Usage

NONR(run,...,command,project = getwd(),wait = TRUE,grid = FALSE,concurrent = grid & wait,udef= FALSE,invisible=udef,compile = TRUE,execute = TRUE,split = FALSE,checkrunno = TRUE,checksum = TRUE,diag = wait,fdata = TRUE,logtrans = FALSE,nice= TRUE,epilog = NULL,dvname = NULL,grp = NULL,grpnames = NULL,cont.cov = NULL,cat.cov = NULL,par.list = NULL,eta.list = NULL,missing = -99,interface='autolog.pl',q='all.q',pe=NA)

NONR 173

Arguments

run vector of control stream names. Typically integer. e.g. 1:10 corresponds to 1.ctl,2.ctl, ... 10.ctl.

command path for a script to run NONMEM, e.g., command=’C:/nm6/test/nm6.pl’. Thescript is assumed to be an NMQual-generated wrapper for NONMEM execution,but may also be arbitrarily defined by the user (udef=TRUE). In the former case,appropriate arguments and modifiers are added to build a typical NMQual com-mandline (nm.pl or autolog.pl), conditionally wrapped in the arguments for atypical grid commandline (qsub). The path may be given relative to the currentdirectory. command may be a character vector of length greater than one: eachelement will be run in succession.If command is missing, an attempt will be made to locate a NONMEM installa-tion using findNonmemCommand (as of package version 5.15). DISCLAIMER:it is the responsibility of the user to ensure that the command thus-identified isappropriate.

project directory in which run-specific subdirectories will be created. Typically alsocontains original control streams. Use an absolute path (safer) or specify relativeto the current working directory.

wait If wait is FALSE (e.g. for large batches of simulations or bootstraps) and gridis TRUE, the job will run asynchronously and no cleanup or plotting will be at-tempted. Default TRUE, gives synchronous runs on the grid, but these are usuallylimited in number. New in version 5.22 (replaces boot). wait also controls thedefaults for diag and sync): see runNonmem.

grid whether NONMEM execution should be wrapped in a call to Sun Grid Engine’sqsub utility. FALSE by default. Set to TRUE explicitly for regular runs using agrid. Coerced to FALSE for Windows.

concurrent Should the runs represented by elements of run be run concurrently as separateprocesses? Normally TRUE if grid is TRUE, since this is the primary advantageof using a grid. Coerced to FALSE on Windows. Concurrency is implementedusing the package fork.As of version 5.22, this argument defaults to TRUE only for regular runs on thegrid. Unsynchronized (wait is FALSE) runs on the grid return control to theconsole almost immediately (sync=’n’) so there is little advantage for each runto have its own process.

udef a logical indicating whether command is user defined. If so, the command issimply wrapped in a system call rather than pre-converted to a (possibly grid-ready) NMQual commandline. Default: FALSE

invisible intern, minimized, and invisible can be specified for the system call thatruns NONMEM. metrumrg will largely ignore these on a unix-like platform.For Windows, invisible is TRUE by default when udef is TRUE, and FALSEotherwise. If FALSE, NONMEM output will be displayed in a command windowduring the run. Set invisible=TRUE to suppress this display. See the Windowshelp for system. To explore interactively, use debug(runCommand).

compile whether to compile NONMEM (i.e., make nonmem.exe). Set to FALSE if youalready did this in a previous step and merely want to execute.

174 NONR

execute whether to execute the compiled NONMEM (i.e., invoke nonmem.exe). Setto FALSE if you merely want to compile, e.g. to verify compile success withoutcommitting to a run. You can run the compiled object later with compile=FALSE.

split whether to compile and execute as separate steps. If both compile and executeare TRUE, the run can be split into two separate steps. Though split, compile,and execute can be manipulated independently, it makes no sense to split a rununless compile and execute are both TRUE. The greatest advantage to splittingis realized on a grid, with grid=TRUE: runs will be split and compile steps willby default be run in their own queue, for efficiency.

checkrunno whether to check/correct the control stream to ensure that standard uses of theNONMEM control stream name match the name listed in run vector. De-fault: TRUE. For files, e.g. ../3.TAB, path separator must be that recognizedby dirname and basename. Only one usage per line of text will be fixed.‘Standard’ uses currently include: the first word after $PROB(LEM) (not count-ing RUN or RUN\#); ‘*.tab’ (case insensitive); ‘*par.tab’ (case insensitive);‘*.msf’ (case insensitive) except on a line that starts with $MSFI.

checksum If TRUE (default), checksums are requested from nm.pl when wrapping NON-MEM execution. FALSE is useful for development.

diag whether to plot standard diagnostic plots. Default: TRUE for synchronized runs.You can override the default file name by passing plotfile. See PLOTR fordetails. Also see Note below for required control stream syntax, e.g. expectedtables.

fdata whether to attempt deletion of NONMEM files FDATA and PRDERR. Default:TRUE.

logtrans passed to PLOTR

nice whether the NONMEM run directory, based on run, is deleted or simply emp-tied prior to the execution of NONMEM. If nice=TRUE (default), hidden files(as defined for all.files in the function dir) are not deleted, e.g., any .svndirectory.

epilog user-defined function or script to call at end of NONR or PLOTR. A non-nullargument that cannot be coerced by match.fun to a function will be treatedas a filename to be sourced. All the arguments normally available to PLOTR(run, project, dvname, logtrans, grp, grpnames, cont.cov, at.cov, par.list, eta.list, missing,etc) will be available to epilog, as well as any extra arguments you pass toNONR or PLOTR. A function can declare any of these, but should at minimumcontain the . . . argument. A script can expect them to be present. See also‘inst/example/epilog.R’ in this package. To see exactly what is available,try epilog=function(...)cat(names(list(...))).

dvname name of the dependent variable to use as a label for the diagnostic plots. Default:DV.

grp passed to PLOTR

grpnames passed to PLOTR

cont.cov passed to PLOTR

cat.cov passed to PLOTR

NONR 175

par.list passed to PLOTR

eta.list passed to PLOTR

missing passed to PLOTR

interface the name of a function to prepare NONMEM command lines

q choice of queue, passed to qsub

pe choice of parallelization environment, passed to qsub; implementation-specific:see your system administrator

... additional arguments passed to functions that accept them. For example, youcan pass onefile=FALSE to pdf, called by PLOTR. You can also pass additionallattice arguments to modify the diagnostic plots. You can gain finer control ofrun behavior by modifying arguments to runNonmem, e.g. purge=FALSE.Flags recognized by Sun Grid Engine’s qsub are accepted by a like-named wrap-per (this effect replaces the older SGEflgs argument). Example: to set a max-imum run length of one hour and get an email if the run goes over one hourand is killed, include l=’h_rt=1:0:0’, m=’e’,M=’[email protected]’.Passing N, o, e, V, j, q, sync, shell, b, or cwd will override defaults. You canpass multiple instances of an argument if qsub allows it. passing L will over-ride a constitutive instance of l in runCommand. Values are character vectors.Lengths greater than one result in element-wise paste operations: a vector ofcorresponding length will be returned.

Details

NONR is currently implemented as a wrapper that calls runNonmem for each element in run. It createsa like-named subdirectory for each run in project. It looks for <run>.ctl in project, cleans itup as necessary, and writes it to the subdirectory, in which context NONMEM is invoked (usingrunCommand). The output of NONMEM will be ‘<run>.lst’ in the subdirectory. Files matchingpatterns in purgeRunDir:standard will be removed. Attempts will be made to run PLOTR andepilog. Then a ‘complete’ message is printed.

As of version 5.22, parallelization is directly supported. <run>.pnm is copied to the subdirectory, ifpresent in the same directory as <run>.ctl. If not, template.pnm is copied to the subdirectory (ifpresent in the same directory as <run>.ctl) and is renamed <run>.ctl. Use an NMQual-mediatedNONMEM installation that expects this convention.

File names and locations can be manipulated somewhat, i.e., by over-riding runNonmem’s defaultsfor rundir, outfile, streams, ctlfile, and remove.

Value

an invisible list of the results of calls to runNonmem

Note

Specific control stream syntax is expected when running NONR and the other functions present in themetrumrg package. The list of syntax requirements are as follows.

• $PROB should be followed by ‘RUN\#’ then a number representing the control stream num-ber. No commas should be used in the $PROB statement. ‘PROBLEM’ is an alternative for

176 NONR

‘PROB’. The run number is the first space-delimited alphanumeric sequence after PROB(LEM),ignoring RUN(\#). No ampersands are allowed in the problem statement.

• The datafile name and relative path needs to be on the first line of the $DATA record immedi-ately following ‘$DATA’.

• A relative datafile path must be specified relative to runNonmem:rundir, typically a subdirec-tory of project. For example, ‘3.ctl’ will actually run as ‘path/project/3/3.ctl’; if itsdatafile is ‘path/data/DATA3’, then 3.ctl should specify “$DATA ../../data/DATA3”.

• The NONMEM datafile must contain a ‘C’ column containing only C’s or periods(‘.’). Typi-cally this is the first column.

• The ‘*.TAB’ file in the “$TABLE” step must contain an EVID column for plotting purposes.In the case of “$PRED” models, this can be a dummy column in the data file.

• The NONMEM data file must contain a column with a header of ‘ID’ for plotting purposes.

• File paths for ‘MSF’ files and ‘TAB’ files, etc., are generally expected to be relative paths, using‘/’ as the directory separator. File paths with no separator are assumed to be relative to thedirectory in which the control stream is run: ‘./’ may be prepended. E.g. “$TABLE EVIDFILE=100.tab” is taken as “$TABLE EVID FILE=./100.tab”.

• $TABLE statments should include the ONEHEADER option, or problems may result.

• Avoid the use of ampersands and greater-than, less-than symbols in comments: they confusexml processors.

PLOTR will automatically generate CWRES plots if required files are present in NONMEM rundirectory. See help for compute.cwres for instructions on generating the files required for CWRESplots. PLOTR expects etas and model parameters to be output in the ‘*par.TAB’ file and variablesfor diagnostic plots to be output in the ‘*.TAB’ file, where ‘*’ represents the control stream number.Additional $TABLE records can be present in the control stream but these are not used/needed byPLOTR. Mechanisms and expectations are somewhat different for NONMEM7.

Author(s)

written by Bill Knebel; modified by Tim Bergsma.

References

http://metrumrg.googlecode.com

See Also

• runNonmem

• PLOTR

Examples

## Not run:#vignette:metrumrgURL('example/project/script/model.pdf')

#Assuming an NMQual-mediated NONMEM wrapper: /opt/NONMEM/nm72/nmqual/autolog.pl

omegacor 177

#Assuming this is some script directory, and contol streams (e.g. 1.ctl) are in# a sibling directory "nonmem"

#regular run, no gridpath <- '/opt/NONMEM/nm72/nmqual/autolog.pl'NONR(run=1,command=path,project='../nonmem',wait=TRUE, #defaultgrid=FALSE, #defaultdiag=TRUE #default)

#regular run on gridNONR(run=1,command=path,project='../nonmem',wait=TRUE, #defaultgrid=TRUE,diag=TRUE #default)

#bootstrap run, no grid (uncommon)NONR(run=1,command=path,project='../nonmem',wait=FALSE,grid=FALSE, #defaultdiag=FALSE #default)

#bootstrap run on gridNONR(run=1,command=path,project='../nonmem',wait=FALSE,grid=TRUE,diag=FALSE #default)

## End(Not run)

omegacor Convert NONMEM Omega Covariance Matrix to Correlation Matrix

178 omegacor

Description

These functions acquire omega or sigma covariance matrix elements for a NONMEM 7 run andcalculate the correlation matrix. Run and project are used to calculate the .ext file name, which isread into memory as a pxml object, and then converted to unilog format. Directly supplying extfile,pxml, or unilog renders all previous arguments moot. Not vectorized: run should be scalar.

Usage

unilogcor(pattern,run=0,project=getwd(),tool='nm7',extfile=file.path(project,run,paste(run,'ext',sep='.')),pxml=as.pxml.ext(extfile),unilog=as.unilog.pxml(x=pxml,run=run,tool=tool,...),...)omegacor(run,project=getwd(),...)sigmacor(run,project=getwd(),...)

Arguments

pattern a pattern to seek in the parameter column of a unilog (anchored at the start ofeach string)

run name (number) of a run

project project directory (parent of run directory)

tool largely irrelevant; only ’nm7’ is supported

extfile name of .ext file, e.g. run.ext

pxml internal xml format for parameter data

unilog unilog format; as returned invisibly by rlog

... passed to unilogcor, else unused

Value

correlation matrix

Ops.keyed 179

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• cov2cor

• rlog

Ops.keyed Operator Syntax for Joining Keyed Data Frames

Description

These functions implement a concise syntax for joining objects of class c(’keyed’, ’data frame’).+ produces an outer join, & produces an inner join, and | gives a left join. * produces a column-stableouter join (same columns and order as for x).

By default, - drops rows in x that have matching rows in y. / drops rows in x that do not havematching rows in y.

^ gives a serial left join: x is joined cumulatively with static variants of y, using left subsets of thekey (e.g. subj, subj-time, subj-time-cmt, etc.).

!, a unary operator, returns rows in x that have NA keys or duplicate/duplicated keys.

The syntax can be extended to subclasses of keyed by writing additional proxy methods. Note,however, that proxy methods may be eliminated in future versions for simplification.

Usage

## S3 method for class 'keyed'Ops(e1, e2)plus.keyed(x, y)times.keyed(x, y)and.keyed(x, y)minus.keyed(x, y)divide.keyed(x, y)left.keyed(x, y)raised.keyed(x, y)

Arguments

e1 left argument to Opse2 right argument to Opsx left argument to proxiesy right argument to proxies

180 Ops.keyed

Details

A concise syntax for joining of data.frames facilitates dynamic assembly of data. This system lever-ages existing operators and dispatch mechanisms. Under Ops dispatch rules, if both left and rightoperands resolve to the same the method, that method is used. Operator methods are already definedfor data.frame, but the existence of class ‘keyed’ creates an opportunity for syntax specification.

Ops.keyed selects a proxy method, and dispatches on the right hand operand. Proxy methods aretext equivalents of simple operators, e.g. the proxy plus corresponds to +. They are necessarybecause direct specification of, say, +.keyed could not be overridden for subclasses of keyed (Opsmechanism would detect conflicting methods for the two operands, and would default to primitives.)

Dispatch on the right hand operand is consistent with a general syntax of data assembly. Fora + b + c ..., results accumulate on the left under a somewhat fixed typology (class), andthe next operand on the right controls the next step of assembly, perhaps invoking a specializedmethod by means of its class (S3 dispatch mechanism).

Operators have been chosen to coordinate intuition about their effects with existing operator prece-dence and a general data assembly pattern. + gives an outer join (merge, with all=TRUE). * furtherrestricts to columns on the left (star suggests stable). & gives an inner join (all=FALSE): mnemoni-cally, rows must match in the left AND right operands to contribute to the result. - suggests removal:it is used for methods that drop rows. | gives a left join (merge, all.x=TRUE). Mnemonically, itsuggests conditioning (as with formulas): use of rows on the right is conditional on existence ofmatches on the left. Right joins are currently not implemented, but most can be expressed as leftjoins by rearrangement. ! invokes the proxy not.keyed, which is the best mnemonic: rows arereturned that have problematic keys (NA or duplicates), i.e. “not keyed” correctly.

Operators +,*,/ and - have higher precedence than &,| and !. Within groups, operators haveequal precedence and resolve left to right (see ?S3groupGeneric). A common assembly sequenceis one or more full joins followed by one or more left joins. Correspondence to the existing order ofoperations minimizes the need for parenthetical grouping of terms (which is available nonetheless).

Proxy methods have been defined on these operators for class ‘keyed’. Users can implement differ-ing assembly operations by creating additional classes and defining proxy methods for them. Thisis discouraged, however, as proxy methods may be eliminated in future versions.

Value

keyed data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.nm

• static.keyed

Ops.keyed 181

Examples

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

dose + sampdose * sampdose & sampsamp - dosesamp / dosedose | demodemo | dosedemo ^ dose

a <- data.frame(subj=c(1,1,1,2,2,2,3,3,3),time=c(0,1,2,0,1,2,0,1,2),conc=c(1,2,3,1,2,3,1,2,3)

)a <- as.keyed(a,c('subj','time'))

b <-data.frame(subj=c(1,1,2,2,3,3),time=c(0,2,0,2,0,2),conc=c(1,3,1,3,1,3),crcl=c(5,5,6,6,7,7),pred=c(2,4,2,4,2,4)

182 ord.matrix

)b <- as.keyed(b,c('subj','time'))a|ba^b # note imputation of apparently-constant crcl

ord.matrix Give the Order of a Symmetric Matrix or Half Matrix

Description

The dimensions of a symmetric matrix are equal; this value is, by definition, the order of the matrix.For class halfmatrix, the order is found using a quadratic expression with length as an argument.

Usage

## S3 method for class 'matrix'ord(x, ...)## S3 method for class 'halfmatrix'ord(x, ...)

Arguments

x symmetric matrix or halfmatrix

... extra arguments, ignored

Details

It is an error if x is a matrix but not symmetric. If x is a vector of appropriate length its order can befound by specifying the method explicitly, even if x is not classed as halfmatrix: ord.halfmatrix(x).

Value

scalar numeric

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

is.square.matrix, isSymmetric.matrix half.matrix

packageCheck 183

Examples

ord(diag(4))ord(half(diag(4)))ord.halfmatrix(1:10)

packageCheck Load a Package and Run Package-level Examples for Testing Purposes

Description

packageCheck attempts to load the specified package and to run example with the package nameas an argument.

Usage

packageCheck(x,lib.loc=NULL)

Arguments

x scalar character, the name of a single package

lib.loc the library to check, passed to library

Details

Many packages do not have package-level examples; the call to example in such cases does nothing(warnings are suppressed).

Value

an scalar character string: zero if the package does not load or if example generates an error;otherwise, the package version.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• accept

• acceptance

• library

184 panel.densitystrip

panel.densitystrip Display Distributions with Respect to Reference Values

Description

These are panel functions that compare distributions with respect to reference values. panel.densitystripplots a filled polygon for each unique value of y. panel.cuts calculates the portion of each distri-bution (unique y) falling within specified limits. panel.ref shades a swath of the panel betweenspecified limits of the primary axis. covplot uses the other panel functions to assemble a sampledisplay of covariate data.

Usage

panel.densitystrip(x,y,horizontal,col.line,fill,factor,border=col.line,col=fill,...)panel.ref(

x,y,col = 'grey90',horizontal,rlim,...

)panel.cuts(

x,y,cuts,col,col.line,text=col.line,horizontal = TRUE,offset = -0.2,increment = 0,format = function(x,...) as.numeric(round(x/sum(x) * 100)),include.range = TRUE,zero.rm = TRUE,cex=0.7,...

panel.densitystrip 185

)panel.covplot(

x,y,ref=1,rlim=ref * c(0.75,1.25),cuts=ref * c(0.75,1,1.25),horizontal=TRUE,border='black',fill='grey',text='black',shade='grey90',col='white',...

)unitDensity(x,...)

Arguments

x numeric

y numeric

horizontal if TRUE, strips run horizontally (x is primary axis)

col.line panel.density: polygon border color if border not specified; panel.cuts:text color if text not specified

fill polygon fill color if col not specified

factor relative height of the density polygon

border polygon border color

col panel.density: polygon fill color; panel.ref: reference area fill color; panel.covplot:color of cut lines panel.cuts: ignored

... extra arguments passed to other functions

rlim length 2 vector: the limits of the shaded region

cuts the values at which to divide the primary axis

text text color for cut statistics

offset distance from nominal value on secondary axis, at which to plot cut statistics

increment distance from nominal value on primary axis, at which to plot cut statistics

format a function to post-process counts of elements between cuts (should accept . . . )

include.range if TRUE, cuts is supplemented with the range of the data

zero.rm If TRUE, zeros are not printed

cex scale factor for text

ref position of a black reference line; may be NULL

shade reference fill color

186 panel.densitystrip

Details

Unlike panel.densityplot, panel.densitystrip has both x and y arguments. In panel.stripplotand panel.bwplot, panel data is implicitly subset by the discrete values on the secondary axis. I.e,visual elements are panel subsets. Here, panel data is explicitly subset using panel.stratify. (Thesame pertains to panel.cuts). Densities are calculated using the default arguments of density(alternatives will be passed to density if supplied). unitDensity rescales densities so that themaximum value is one. panel.densitystrip uses factor (traditionally used to control jitter)to rescale densities again.

A grouping variable can be used at the ‘panel subset’ level to give the same graphical parameters toseveral subsets, e.g., several polygons can share a color.

For panel.cuts, calculated values are by default converted to character and printed below (horizontal==TRUE)the density strips. Zeros are not printed by default, for less visual clutter; zeros are stripped beforethe conversion to character. The actual values calculated are ‘bin counts’, i.e., the number of el-ements in each vector that fall between adjacent cut points. Only inner cuts need be specified, asthe limits of the data are included by default as the outer limits. Cuts are converted to percent bydefault; use format=function(x)x to get actual counts. cex will control the size of the text.

panel.covplot is optimized for a sample presentation of covariate effects. Values are assumed tobe relative, so the center cut is 1 with +/- 25 region. Five color features are specifiable. ref, rlim,and cuts can be specified independently.

Formally, these panel functions are alternatives to panel.stripplot, and thus can be passed tostripplot. xyplot gives similar results, and bwplot seems to give identical results.

Value

used for side-effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• densityplot

• bin

• panel.stratify

Examples

## Not run: metrumrgURL('example/project/script/covplot.pdf')

#a bootstrap of a pharmacokinetic modelset.seed(0)boot <- data.frame(CL = exp(rnorm(100,mean=3, sd=0.25)),

panel.densitystrip 187

WT = exp(rnorm(100,mean=-0.25,sd=0.25)),MALE = exp(rnorm(100,mean=0.3, sd=0.25)),ASIAN = exp(rnorm(100,mean=-.1, sd=0.05)))

#Model: CL = theta1 * (WT/70)**theta2 * theta3**MALE * theta4**ASIAN

#Normalize the structural parameter.boot <- within(boot, CL <- CL/median(CL))

#Realize the submodel for non-normal instances of the continuous covariate.boot <- within(boot, WT_35 <- (35/70) ** WT)boot <- within(boot, WT_140 <- (140/70) ** WT)boot$WT <- NULL

#(Categorical covariates are already expressed proportionally.)

#Reorganize the table. rev() anticpates bottom-up plotting.boot <- melt(rev(boot))

#Limit to 90% of the data, for independence from number of bootstraps.boot <- boot[with(boot,value >= reapply(value,variable,quantile,0.05) &value <= reapply(value,variable,quantile,0.95)),]

#plot using panel.covplot().stripplot(variable~value,boot,panel=panel.covplot,xlab='relative clearance')#with groupsstripplot(variable~value,boot,groups=contains('WT',variable),panel=panel.covplot,xlab='relative clearance')

#variationsdata(crabs)soup <- melt(crabs,id.var=c('sp','sex','index'))soup$relative <- with(soup,value/mean(value[variable=='CL']))soup$grp <- 'depth'soup$grp[contains('W',soup$variable)] <- 'width'soup$grp[contains('L',soup$variable)] <- 'length'stripplot(variable~value,soup,panel=panel.stratify,panel.levels=panel.densitystrip)

188 panel.hist

stripplot(variable~relative|sp+sex,soup,panel=panel.stratify,panel.levels=panel.densitystrip)stripplot(variable~relative|sp+sex,soup,panel=panel.covplot)stripplot(variable~relative|sp+sex,soup,panel=panel.covplot,groups=grp,auto.key=TRUE,cex=0.5,offset=0.2)stripplot(value~variable|sp+sex,soup,groups=grp,panel=panel.covplot,auto.key=TRUE,horizontal=FALSE,ref=NULL,rlim=c(10,50),lty=3,lwd=2,border='transparent',text='blue',shade='turquoise',col='magenta',cuts=c(10,20,30,40,50))

panel.hist Plot Histograms Flexibly

Description

histogram and panel.histogram in package lattice (expected) are univariate. Here, we present abivariate histogram panel function for use, e.g., with stripplot. panel.bar adds line segments,appropriate for reference lines in a histogram. unitHist calls hist but returns histogram specifi-cations that have been rescaled so that maximum bar height is 1.

panel.hist 189

Usage

panel.hist(x,y,level,horizontal,col.line,fill,factor,border=col.line,col=fill,offset=-0.5,font,fontface,...)panel.bar(x,y,level,horizontal,col,col.line,fill,factor,font,fontface,...)unitHist(x, plot = FALSE, ...)

Arguments

x vector

y vector

level the level at which to draw the histogram, typically supplied by panel.stratify

horizontal typically TRUE

col fill color (ignored for panel.bar)

col.line border color if border not supplied

fill fill color if col not supplied

factor factor by which to expand or attenuate bar heights relative to unity

border border color

offset amount to raise the base of each bar relative to the level

... passed to other functions

font ignored

fontface ignored

plot passed to hist

Value

unitHist returns class histogram with an extra element named ‘heights’. ‘heights’ is proportionalto density, but normalized relative to maximum density. Panel functions are used for side effects.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• panel.stratify

190 panel.stratify

panel.stratify Handle Each Level of a Stripplot Separately

Description

Just as panel.superpose handles each group of data separately, panel.stratify handles each‘level’ of data separately. Typically, levels are the unique values of y (horizontal==TRUE) that re-sult from a call to stripplot or bwplot. The default panel functions treat all levels simultaneously.Plotting some transformation of the data (e.g. density polygons for each level) is much easier if thelevels are presented individually.

Usage

panel.stratify(x,y,type = 'p',groups = NULL,pch = if (is.null(groups))plot.symbol$pch else superpose.symbol$pch,col,col.line = if (is.null(groups))plot.line$col else superpose.line$col,col.symbol = if (is.null(groups)) plot.symbol$col else superpose.symbol$col,font = if (is.null(groups))plot.symbol$font else superpose.symbol$font,fontfamily = if (is.null(groups)) plot.symbol$fontfamilyelse superpose.symbol$fontfamily,fontface = if (is.null(groups)) plot.symbol$fontfaceelse superpose.symbol$fontface,lty = if (is.null(groups))plot.line$lty else superpose.line$lty,cex = if (is.null(groups)) plot.symbol$cex else superpose.symbol$cex,fill = if (is.null(groups)) plot.symbol$fill else superpose.symbol$fill,lwd = if (is.null(groups)) plot.line$lwd else superpose.line$lwd,horizontal = FALSE,panel.levels = 'panel.xyplot',...,jitter.x = FALSE,jitter.y = FALSE,factor = 0.5,amount = NULL)

Arguments

x See panel.xyplot

panel.stratify 191

y See panel.xyplot

type See panel.xyplot

groups See panel.xyplot

pch See panel.xyplot

col See panel.xyplot

col.line See panel.xyplot

col.symbol See panel.xyplot

font See panel.xyplot

fontfamily See panel.xyplot

fontface See panel.xyplot

lty See panel.xyplot

cex See panel.xyplot

fill See panel.xyplot

lwd See panel.xyplot

horizontal See panel.xyplot

panel.levels a function to handle each unique level of the data

... See panel.xyplot

jitter.x See panel.xyplot

jitter.y See panel.xyplot

factor See panel.xyplot

amount See panel.xyplot

Details

panel.stratify is defined almost identically to panel.xyplot. panel.levels is analogous topanel.groups. panel.levels may want to handle special cases of col, which may be missing ifgroups is NULL and may be NA if groups is not NULL (set to NA by panel.superpose).

x and y are split into subsets by whichever of them represents levels (y if horizontal is TRUE, xotherwise). Corresponding subsets of x and y are forwarded one at a time, along with the otherarguments, to panel.levels. Additionally, the current value of level as well as the completevector of levels are available to panel.levels.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

192 parameter2wiki

See Also

• panel.covplot

• panel.densitystrip

• panel.hist

• panel.xyplot

parameter2wiki Convert Parameter Labels to Wikimath

Description

Convert parameter labels for thetas, omegas, sigmas, and etas to wikimath. See wikimath.

Usage

parameter2wiki(x,lowercase='is.fixed',...)

Arguments

x character, or coercible to character

lowercase functions of x identifying elements to coerce to lower case

... ignored

Details

This function expects a vector of labels such as "THETA1" or "OMEGA2.1". It converts them totheir wikimath equivalents. Thetas are coerced to the lower case representation by default, whereasomegas, sigmas, and etas will be upper case (set lowercase to NULL for no coercion). The resultcan be passed conveniently to wiki2latex for table development.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

params 193

See Also

• wiki2latex

• wiki2parameter

• tos

• titleCase

Examples

x <- parameter2wiki(c("THETA1","OMEGA1.2","SIGMA1.1"))xwiki2latex(x)## Not run: as.pdf(wiki2latex(x))

params List Documented Parameters

Description

Returns a vector of parameters available in a specially-formatted XML document, preserving theorder.

Usage

params(within, by = "name", type = "parameter", ...)

Arguments

within an XML ‘document’ containing parameter elements (character)

by the parameter attribute by which to interpret x

type the element type to seek in ‘within’

... ignored

Details

This function is argumented nearly identically to lookup, except that x is missing. Whereas inlookup, one is looking for details about elements of x, in params, one is asking what those elementsmay be.

Value

character

Author(s)

Tim Bergsma

194 parens

References

http://metrumrg.googlecode.com

See Also

• lookup

• partab

parens Wrap Text in Parentheses

Description

Wrap text in parentheses. Useful when formating latex tables.

Usage

parens(x, ...)

Arguments

x character

... ignored

Details

Text is wrapped in parentheses, with no intermediate spaces.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• glue

Examples

parens('x')

partab 195

partab Construct a Parameter Table

Description

Merges data from rlog and lookup to describe model run parameters.

Usage

partab(run,project = getwd(),tool = "nm7",file = filename(rundir, run, ".ctl"),rundir = filename(project, run),nmlog = file.path(rundir, "NonmemRunLog.csv"),nmout = filename(rundir, run, ".lst"),x = params(within = within, by = by, type = type, ...),within = ctl2xml(readLines(file)),by = "name",as = c(NA, "estimate", "unit", "prse"),type = "parameter",append = NULL,purge = FALSE,...)wikitab(run,project = getwd(),tool = "nm7",file = filename(rundir, run, ".ctl"),rundir = filename(project, run),nmlog = file.path(rundir, "NonmemRunLog.csv"),nmout = filename(rundir, run, ".lst"),x = params(within = within, by = by, type = type, ...),within = ctl2xml(readLines(file)),by = "model",type = "wiki",append = NULL,purge = FALSE,...

)

Arguments

run scalar run name (number)

project path to the directory containing run subdirectories

196 partab

tool ‘nm6’ or ‘nm7’: controls methodology. Defaults to ’nm7’ as of version 5.18.

file the run-specific input file to read, contra rlog

rundir path to run subdirectory

nmlog The run-specific input file to read (nm6 only). See rlog.

nmout The run-specific NONMEM output file to read (nm7 only). See rlog.

x a vector of parameter names (character)

within an XML ‘document’ containing parameter elements (character)

by the parameter attribute by which to interpret x

as vector of parameter attributes as which to describe x. Where NA, the text valueof the element (if any) is returned.

type the element type to seek in ‘within’

append ignored; NULL is passed to rlog

purge ignored; FALSE is passed to rlog

... passed to lookup and rlog

Details

The idea here is to associate pre-specified model-specific identifiers with model output. Identifiersderive from some text file, such as a NONMEM model control stream. partab calls lookup torecover the identifiers, and rlog to access the results. The common key is ‘name’ by default inlookup, and ‘parameter’ by default in rlog. Caution is advisable when using these terms in otherways.

lookup only allows one value for as. Here, as can be a vector. The special value NA returns the textelement for the parameter (cs. NULL in lookup).

This mechanism allows messy model details to be abstracted to a more appropriate location than amodeling script. Output is suitable as an argument to latex in package Hmisc.

wikitab is like partab, but only returns the ’model’ attribute (default) and the element text forelements of type ’wiki’ (default). It tries to guess the parameter names from the model attribute,using wikimath conventions (see tos), and then fold in the related details from the run log. wikitabis more restrictive than partab, but it lets all the usual parameter details arise from a single specifi-cation thereof.

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

percent 197

See Also

• lookup

• params

• rlog

• wikimath

• tos

Examples

## Not run: metrumrgURL('example/project/script/parameters.pdf')

percent Calculate Percent.

Description

Format a decimal as percent, specifying significant digits.

Usage

percent(x, digits = 3, ...)

Arguments

x numericdigits passed to signif

... ignored

Value

numeric

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• signif

Examples

percent(.53421)

198 plot.nm

plot.nm Plot An Object of Class nm

Description

This specializes the generic plot for nm objects. Standard arguments are derived and passed,together with extra arguments, to a suite of diagnostic plots nmPlots.

Usage

## S3 method for class 'nm'plot(x,which = NULL,dvname = 'DV',ivname = 'AMT',covariates = NULL,categorical = NULL,continuous = NULL,by = NULL,...)

Arguments

x nmwhich names or numbers for subsetting nmPlots

dvname column name for the dependent variableivname column name for the independent variablecovariates a list of covariates, guessed by defaultcategorical a list of categorical covariates, guessed by default, ignored where not in covariates

continuous a list of continuous covariates, guessed by default, ignored where not in covariates

by column name(s) for extra plotting hierarchy (lattice levels); currently unimple-mented

... extra arguments passed to nmPlots

Details

Time within subject is rescaled to start at zero. Covariates are guessed to be everything that isnon-structural. By default, covariates with 7 or more unique values are continuous, and the restare categorical. But you can reallocate, even assigning the same column as both categorical andcontinuous.

Value

a list of trellis objects

plotfilename 199

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• nmPlots

• as.nm

plotfilename Make a Name for a Diagnostic Plot File

Description

Make a name for a diagnostic plot file, given supplied arguments.

Usage

plotfilename(run,dir=getwd(),grp=NULL,onefile=TRUE,stem='DiagnosticPlotReview',pext=if(onefile) '.pdf' else '_%03d.pdf',...)

Arguments

run run name

dir directory name

grp filename modifiers, see NONR

onefile includes a counter if FALSE

stem filename stem

pext extension, typically ‘pdf’

... ignored

Value

character

200 PLOTR

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

PLOTR Create Diagnostic Plots for a NONMEM Run

Description

PLOTR is a function to generate diagnostic plots and/or covariate evaluation plots following a suc-cessful NONMEM run. It is called by NONR if diagnostic plots are requested or can be calledindependently following a NONMEM run. Plots use the pdf device. Specific control stream syntaxis required: see Note under NONR .

Usage

PLOTR(run,...,project=getwd(),rundir=filename(project,run),grp = NULL,onefile=TRUE,plotfile=plotfilename(run,project,grp,onefile),logtrans = FALSE,dvname = 'DV',epilog=NULL,grpnames = NULL,cont.cov = NULL,cat.cov = NULL,par.list = NULL,eta.list = NULL,missing = -99,estimated = NULL,superset = FALSE)

PLOTR 201

Arguments

run a control stream name, typically integer

project the directory containing run subdirectories

rundir path for the NONMEM run directory (‘project/*’); passed to dataSynthesis

grp item in NONMEM data file or output table file (default) that can be used to con-dition plots generated by PLOTR. Default value is NULL. Example: grp=c(’SEX’).Can be more than one, e.g,. grp=c(’SEX’,’TRT’). When specifying grp, youcan also specify include.all=TRUE, which will be understood by diagnosticPlotsand cause the data to be plotted collectively as well as group-wise.

onefile whether to produce one output file or many; passed to pdf

plotfile file name for diagnostic plots, if any. Default combines ‘DiagnosticPlotReview’with the run number, and grp if present. A counter is supplied if onefile=FALSE.You can specify an arbitrary name, coordinating with the value of onefile. Anyasterisk will be replaced with the run name.

logtrans Whether to transform the NONMEM output variables DV, NPRED, CPRED, CPREDI, EPREDPRED, and IPRED. Default: FALSE.

dvname name of the dependent variable to use as a label for the diagnostic plots; default:DV

epilog User-defined function or script to call at end of NONR or PLOTR. A non-null argu-ment that cannot be coerced by match.fun to a function will be treated as a file-name to be sourced. All the arguments normally available to PLOTR (run, project, dvname, logtrans, grp, grpnames, cont.cov, at.cov, par.list, eta.list, missing, etc)will be available to epilog, as well as any extra arguments you pass to NONR orPLOTR. A function can declare any of these, but should at minimum contain the. . . argument. A script can expect them to be present. See also ‘inst/example/epilog.R’in this package. To see exactly what is available, try epilog=function(...)cat(names(list(...))).

grpnames optional vector of names for grp item. Vector length must equal number ofconditions in grp and must have an order corresponding to an increasing sort ofgrp. Default value is NULL. Example: grpnames=c(’Male’,’Female’)

cont.cov vector of continuous covariate names. Names must match those used as columnheaders in the data file (identified in the control stream). Values are retrievedfrom the data file if not part of the NONMEM $TABLE step. Default value isNULL. Example: cont.cov=c(’AGE’,’WT’,’CLCR’)

cat.cov vector of categorical covariate names. Names must match those used as columnheaders in DataFile. Values are retrieved from the data file if not part of theNONMEM $TABLE step. Default value is NULL. Example: cat.cov=c(’SEX’,’FOOD’)

par.list vector of NONMEM model parameter names. Values are retrieved from ‘*par.TAB’created in NONMEM if not in ‘*.TAB’. Default value is NULL. This can be a su-perset of parameters but only those present in NONMEM output table will beused. Example: par.list=c(’CL’,’V’,’V2’,’Q’)

eta.list vector of NONMEM model random effect names. Values are retrieved from‘*par.TAB’ created in NONMEM if not in ‘*.TAB’. Default value is NULL. Thiscan be a superset of random parameters but only those present in NONMEM out-put table will be used. Example: eta.list=c(’ETA1’,’ETA2’,’ETA3’,’ETA4’)

202 PLOTR

missing numeric item that defines value used to represent missing items in the NON-MEM data file. Default value is ’-99’.

estimated character vector of names for items that NONMEM estimates. Used to annotateparameter and gradient search plots.

superset (experimental) whether to use superset as an intermediate for dataset creation(instead of dataSynthesis). Could give time-varying covariates, whereas thedefault gives only static covariates.

... additional arguments passed to functions that accept them. For example, youcan pass onefile=FALSE to pdf. You can also pass additional lattice argumentsto modify the diagnostic plots.

Details

PLOTR creates a plotting dataset using dataSynthesis. It passes this dataset to each of diagnosticPlots,covariatePlots, and cwresPlots. It then calls the function named by the epilog argument, ifany. The example epilog (‘example/epilog.R’) calls dataSynthesis itself, and does additionalplotting.

The . . . argument can be used creatively, with appropriate caution. Extra arguments are generallypassed to secondary functions that accept them, and even some that don’t. All the lattice plottingfunctions accept extra arguments, so you may be able to modify the diagnostic plots judiciously(with the caviat that the same arguments will be passed to diagnosticPlots, covariatePlots,and cwresPlots. pdf technically does not accept extra arguments, but any specified argument thatit does accept will be passed.

File names deserve special consideration. plotfile gives the name (or naming strategy) for the di-agnostic plots; it is passed to pdf and has a suitable default. If an alternative is specified, ‘*’ will bereplaced with run, the run name. For example, the default ‘pdf’ name is ‘project/DiagnosticPlotReview_*.pdf’,but you could change it to ‘project/*/DiagnosticPlotReview.pdf’.

Value

data.frame (the plotting data set), returned invisibly

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• NONR

• dataSynthesis

• diagnosticPlots

• covariatePlots

• cwresPlots

pool 203

pool Test Set Relations Among Two Vectors

Description

Test set relations among two vectors.

Usage

pool(x,y)

Arguments

x vector

y vector

Details

The two vectors are tested for elements unique to x, unique to y, and common to both.

Value

list with elements x, y, and both

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• setdiff

• intersect

• %u%

Examples

pool(letters[1:5],letters[4:8])

204 prev

posmat Coerce a Matrix to be Positive Definite

Description

For a square matrix with an all-positive diagonal, elements are limited to 6 significant digits byrounding the diagonal and shrinking off diagonal elements toward zero. The off-diagonals arereduced by 3 percent as necessary until the determinant is positive.

Usage

posmat(x,...)

Arguments

x matrix with only positive diagonal elements

... extra arguments, ignored

Value

matrix

Author(s)

Leonid Gibiansky, modified by Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

posmat(matrix(c(10.00006,20.00006,-30,40),2,2))posmat(matrix(rep(100,4),2,2))

prev Check Some Properties of Vectors

Description

maxChar returns the number of printed characters for the widest element of x. prev calculates theprevious element for each element in x. nxt calculates the next element for each element in x.runhead determines whether each element is the ‘head’ (start) of a run.

prev 205

Usage

maxChar(x)prev(x)nxt(x)runhead(x)

Arguments

x vector

Details

If you forget to round or signif a numeric column, you may get more digits than desired in youroutput file; maxChar can warn you. See examples.

prev is used by runhead. Note that there is no element previous to the first element in a vector, soprev returns NA in that position. nxt is the reverse of prev (literally). Note that next is a reservedlanguage word in R.

If a ‘run’ is a sequence (possibly of length one) of identical successive values in a vector, runheaddetermines whether an element is the first in such a sequence. Note that by definition, the firstelement is the start of a run; thus runhead returns TRUE in that position, even though prev returnsNA.

Value

maxChar: a scalar integer prev: a vector of the same class nxt: a vector of the same class runhead:a vector of logicals

Note

NAs in the argument to runhead give surprising but reasonable results. It cannot be known whetherthey are the heads of runs, nor can it be known whether values immediately following them areheads of runs. To treat NAs deterministically, convert to some definite value first.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

maxChar(c(1.2,1.234))prev(c(1,2,NA,3,3,NA,4))nxt(c(1,2,NA,3,3,NA,4))runhead(c(1,2,NA,3,3,NA,4))runhead(logical(0))runhead(factor(c('a',NA,'a','a','b','b')))

206 purge.dir

purge.dir Purge a Directory

Description

Purge a directory, perhaps nicely.

Usage

purge.dir(dir, nice = FALSE)

Arguments

dir a directory

nice whether to purge system files

Details

If nice==TRUE, system files (as defined for all.files in dir) are not removed.

Value

used for side effects.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runNonmem

purge.files 207

purge.files Purge Files

Description

If dir is a directory, remove files matching the pattern.

Usage

purge.files(pattern, dir = '.')

Arguments

pattern a regular expression

dir a directory path

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• purge.dir

qstat Invoke SGE qstat

Description

Thin wrapper in R for SGE Command Line qstat.

Usage

qstat(f='',...)

Arguments

f character

... extra arguments to ‘qstat’ or system

208 qsub

Details

This is a wrapper. All argument values are character. Values are concatenated using paste, withthe usual effects if any arguments have length greater than one. Arguments may be used more thanonce, and will be represented in the order received. Passing NA results in the argument instancebeing dropped. Use an empty string as the value for a flag that does not take a value, e.g. ‘f’.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• qsub

Examples

## Not run: qstat()

qsub Build Commands to Invoke SGE qsub

Description

Builds one or more commands suitable for invoking Sun Grid Engine’s qsub in a shell.

Usage

qsub(command, ...)

Arguments

command character... extra arguments

Details

This is almost a wrapper, except that it does not actually make the system call. All argument valuesare character. Values are concatenated using paste, with the usual effects if any arguments havelength greater than one. Arguments may be used more than once, and will be represented in theorder received. Passing NA results in the argument instance being dropped. Use an empty string asthe value for a flag that does not take a value, e.g. ‘soft’. Quote the ‘@’ argument in backticks.

random 209

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runCommand

Examples

qsub('nm.pl',`@`='options',hard='',i='stdin',soft='',hard='',N=c('Run3c','Run3e'),hold_jid=c(NA,'Run3c'))#[1] 'qsub -@ options -hard -i stdin -soft -hard -N Run3c nm.pl'#[2] 'qsub -@ options -hard -i stdin -soft -hard -N Run3e -hold_jid Run3c nm.pl'

random Select Random Members of an Object

Description

Select random members of an object.

Usage

## S3 method for class 'data.frame'random(x,n=6L,...)

Arguments

x An object, e.g. data.frame

n number of rows to show

... extra arguments, ignored

Details

The functions head and tail show the first or last parts of an object. random shows an arbitraryportion. Generic, with a method defined for data.frame.

Value

same class as x

210 reapply

Author(s)

Jim Rogers

References

http://metrumrg.googlecode.com

See Also

• head

Examples

random(Theoph)

reapply Apply a Function Across Cells of an Indexed Vector, Giving anIdentically-indexed Result

Description

Like calling tapply but stretching the result to dimensions of x.

Usage

reapply(x, INDEX, FUN, where, ...)

Arguments

x an atomic object, typically a vector

INDEX list of factors, each of same length as x

FUN a function that accepts a vector and returns a vector

where logical, restricting the domain of x

... optional arguments to FUN

Details

The function tapply applies FUN to each cell of a vector, as specified by levels of INDEX. reapplyrepeats that result as necessary to match the number of input elements per cell, and restores theorder to that of the original index. Regardless of the length of the value of FUN, the length of thevalue of reapply is always identical to that of x. If where is specified, elements in x correspondingto FALSE are not passed to FUN. Argument where is recycled as necessary and coerced to logical,with NA set to TRUE.

reapply gives a result similar to stats::ave. However, ave gives a warning if the input for a cellis not a multiple of the output. Also, reapply has a named argument for the index variables, andpasses dots to fun; for ave, dots represent the indices, and any extra arguments to fun need to be

reapply 211

hard-coded, e.g. in an anonymous function (see examples for ave). Finally, reapply returns NAfor any element where some member of INDEX is NA, whereas ave applies FUN to these elementsin isolation.

Value

an atomic object, typically a vector

Note

Caution! If FUN is isometric (output has same length as input, e.g. cumsum but not mean) then use ofwhere may give surprising results. If where is ever FALSE, then the input to FUN will be necessarilyshorter than the required output, and recycling will be in effect.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• tapply

• lapply

• rep

• ave

Examples

theoph <- Theoph[c(1,12,2,13,3,14),]theoph$avg <- with(theoph,reapply(conc,Subject,mean))theoph$avg2 <- with(theoph,reapply(conc,Subject,mean,where=Time!=0,na.rm=TRUE))theoph$sum <- with(theoph,reapply(conc,Subject,cumsum))theophTheoph <- Theoph[Theoph$Subject %in% c(1,2),]Theoph <- Theoph[distance(within=Theoph$Subject) < 4,]Theoph$Subject <- as.character(Theoph$Subject)Theoph$where <- TRUETheoph <- within(Theoph, where[Subject == 2 & conc == 0] <- FALSE)Theoph <- rbind(Theoph, aug(Theoph[1,],Subject = NA))Theoph$misc <- reapply(Theoph$conc,INDEX=Theoph[,c('Subject','Dose')],where=Theoph$where,FUN= `[`,1:3)Theophstopifnot(class(reapply(c('foo','bar'),INDEX=c(1,1),FUN=function(x)x=='foo'))=='logical')

212 resample.data.frame

resample.data.frame Create Replicate Data Sets by Stratified Sampling

Description

resample is generic. A method is defined for data.frame; a convienience wrapper is provided forpassing names of files to be read and then resampled.

Usage

## S3 method for class 'character'as.csv.filename(x, ...)## S3 method for class 'csv.filename'resample(x, ...)## S3 method for class 'filename'resample(x, ...)## S3 method for class 'data.frame'resample(x,names,key = NULL,rekey =FALSE,out = NULL,stratify = NULL,ext='.csv',row.names=FALSE,quote=FALSE,sep=',',replace=TRUE,...)

Arguments

x a data.frame, or (second/third form) a file name for a file to read

names a list of names for replicate data sets; can be a simple vector

key a scalar character value naming the column in x that distinguishes unique indi-viduals, (resampling targets); defaults to row names

rekey If true, key values in resampled data sets will have unique values of key replacedwith consecutive integers, starting at 1.

out a (path and) directory in which to write resulting data sets

stratify A list of factors, the interactions of which will be the levels of stratification.Each factor must have the same length as nrow(x). Or a character vector ofnames in names(x).

ext a file extension

resample.data.frame 213

row.names passed to write.table

quote passed to write.table

sep passed to write.table

replace passed to sample

... extra arguments, passed to sample and write.table

Details

Typical usages are

resample(x, names, ...)resample(as.csv.filename(x), names, ...)resample(as.filename(x), names, ...)

The argument key gives the name of the column in x to identify unique experimental units (individ-uals). If not supplied, a temporary key is constructed from the row names, and sampling occurs atthe row level.

The number of resamplings is controlled by the length of names. names is coerced to character, andeach value is used to name a ‘*.csv’ file, if out is supplied. If out is omitted, a list of data.framesis returned.

stratify is a list of factors, or items that can be coerced to factors. Currently stratify is coercedto a data.frame for convenient manipulation. Empty levels are dropped. If stratify is not supplied,the whole data set is treated as a single level. Otherwise, each resulting data set has as many keysin each level as the original. An error results if key is not nested within stratify.

The default behavior is to sample with replacement (replace=TRUE.) This and other arguments tosample can be modified.

Value

A list of data.frames, or if out is supplied, an invisible list of the numbers of rows of each data.framewritten to file.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• metaSub.character

• sample

214 rinvchisq

Examples

b <- resample(Theoph,key='Subject',names=1:3)d <- resample(Theoph,key='Subject',rekey=TRUE,names=1:3,out='.',stratify=Theoph$Dose < mean(Theoph$Dose))e <- resample(as.csv.filename('1.csv'),names='theoph')

rinvchisq Generate Inverse Chi-square Distribution

Description

Generate inverse chi-square distribution given n, df, and covariance matrix

Usage

rinvchisq(n, df, cov)

Arguments

n the number of values to return

df the degrees of freedom for the distribution. This value reflects the uncertainity inthe distribution. A reasonable starting point would be a value between the num-ber of subjects and the total number of observations used to obtain the estimatesof the variance-covariance matrix.

cov a single parameter

Value

The rinvchisq function returns n parameter deviates for use as simulation parameters.

Author(s)

written by Leonid Gibiansky; modified by Tim Bergsma.

References

http://metrumrg.googlecode.com

riwish 215

riwish Generate Inverse Wishart Distribution

Description

Generates an inverse Wishart distribution for a variance of a random effect. The functions requiresthe specification of degrees of freedom, scale matrix, and precision for each random effect.

Usage

riwish(s, df, prec)

Arguments

s scale matrix for inverse Wishart distribution

df degrees of freedom

prec presision matrix: the mean of riwish is proportional to prec

Value

The variance of the random effect can be drawn from the returned inverse Wishart distribution.

Author(s)

written by Leonid Gibiansky; modified by Tim Bergsma.

References

http://metrumrg.googlecode.com

rlog Generate a Combined Run Log from Multiple NONMEM Runs

Description

Generates a combined run log across specified runs. Appends/overwrites existing file. Attempts topurge certain files in run directory.

216 rlog

Usage

rlog(run,project = getwd(),append = TRUE,tool = 'nm7',file = filename(project,'CombRunLog.csv'),rundir = filename(project, run),nmlog = file.path(rundir,'NonmemRunLog.csv'),nmout = filename(rundir,run,'.lst'),

purge=TRUE,...

)purgeRunDir(dirs,debug = FALSE,standard = c("^F[ISRCMP]", "^OU", "^nonmem", "^nul$","WK", "LNK$", "fort", "^nm", "lnk$","set$", "^gar", "^temp", "^tr", "^new","^Run\\d+\\.o\\d+$", "^prsizes", "log$","worker",if (!debug) c("^FD", "^PR")),extra = character(0),pattern = c(standard, extra),...)

Arguments

run vector of run names (numbers)project path to the directory containing run subdirectoriesappend TRUE: append file; FALSE: overwrite filetool ‘nm6’ or ‘nm7’: controls methodology. Defaults to ’nm7’ as of version 5.18.file The run-generic output file to write. See details.rundir path to run subdirectorynmlog The run-specific input file to read (nm6 only). See details.nmout The run-specific NONMEM output file to read (nm7 only). See details.purge whether to remove files as defined in purgeRunDirdirs character vector: run directories to purgedebug if TRUE, do not delete FDATA and PREDERR by defaultstandard default files to purgeextra other files to purgepattern files to purge: trumps standard and extra if specified... passed to other functions, such as runstate and purgeRunDir

row2tabular 217

Details

rundir, nmlog, and nmout can be vector; or scalar, in which case they may contain ‘*’, to bereplaced with run names on a per-run basis.

To suppress file deletion, supply FALSE for purge.

To suppress log creation on disk, supply a zero length argument for file.

Value

Combined runlog is returned invisibly in the unilog format. Side effect: if file is specified, runlogformat is written to disk.

Note

As of version 5.18, if the attempt to create a unilog for the run fails, rlog generates a surrogate entryfor parameter "min" with value "-1" (moment: "status"). Formerly, the error was converted to awarning and reported at the console.

Author(s)

written by Bill Knebel; modified by Tim Bergsma.

References

http://metrumrg.googlecode.com

See Also

• as.unilog.run

• as.runlog.file

• runstate

row2tabular Format Vector for Latex Tabular Row

Description

Format a vector for use as a row in latex tabular environment.

Usage

row2tabular(x, ...)

Arguments

x vector, coerced to character with paste

... ignored

218 runCommand

Details

Elements are collapsed into a string, with ampersand as the separator.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• tabular.data.frame

Examples

row2tabular(names(Theoph))

runCommand Issue the System Call That Invokes NONMEM

Description

If udef is FALSE, command is passed to nm.pl with supporting arguments. If grid is TRUE, the resultis passed to qsub with supporting arguments. If background is TRUE, ‘&’ is appended to the result.Each element of the result is executed in succession using a system call customized by platform.

Usage

runCommand(command,...,run,rdir,wait,checksum,grid,udef = FALSE,ctlfile,outfile,perl = if (nix()) 'perl -S' else if (!invisible) 'cmd /K perl -S'else 'cmd /C perl -S',intern = invisible,

runCommand 219

minimized = invisible,invisible = FALSE,split = FALSE,N = glue('Run', run, if (split) c('c', 'e') else NULL),o = rdir,e = rdir,L=if(split & is.character(interface) & interface=='nm.pl')c(compileflag(compiler(config(dirname(command)))),NA)else NA,hold_jid = if (split) c(NA, glue('Run', run, 'c')) else NA,V = '',j = 'y',q=if(split) c('compile.q','all.q') else if(!execute)'compile.q' else 'all.q',sync = if (wait) 'y' else 'n',shell = 'n',b = 'y',cwd = '',compile = TRUE,execute = TRUE,background=FALSE,interface = 'nm.pl')

Arguments

command a command to pass to system

run run name

rdir run directory

wait see NONR

checksum see NONR

grid see NONR

udef see NONR

ctlfile see runNonmem

outfile see runNonmem

perl a character string to invoke perl

intern see NONR, passed to system

minimized see NONR, passed to system

invisible see runNonmem

split whether compile and execute should be run separately; defaults to FALSE as ofv. 5.22

N passed to qsub

o passed to qsub

e passed to qsub

L passed to qsub as an instance of ‘l’

220 runCommand

hold\_jid passed to qsub

V passed to qsub

j passed to qsub

q passed to qsub

sync passed to qsub. Bootstrap and simulation runs may occur in large quantities,whereas SGE has an internal limitation on number of synchronized processes.If wait is FALSE, no attempt is made to synchronize the runs.

shell passed to qsub

b passed to qsub

cwd passed to qsub

compile passed to nm.pl

execute passed to nm.pl, influences default for q

background TRUE appends ‘l’ to command lines to put the process in the background. De-funct?

interface the name of a function to prepare NONMEM command lines

... passed to nm.pl and qsub

Details

The argument ‘L’ represents a possibly-constituative instance of qsub’s ‘l’, but is not called ‘l’ sothat other instances of ‘l’ (multiple are allowed) will not accidentally override it. Users can overrideintentionally, of course.

N, L, and hold_jid are coordinated so that if a run is split, compile status is flagged on the compilerun, and the execute run waits for compile to finish.

‘q’ is handled specially. When overriding, be sure to pass a character vector of length one for anormal run, and of length two if split is TRUE (the default when grid is TRUE). By default, allstandalone compile-only runs are diverted to ‘compile.q’, as well as all compile halves of split runs.By default, all execute-only runs as well as the execute halves of split runs are diverted to ‘all.q’.

Value

character vector showing the result(s) of the system call(s)

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• runNonmem

runlog 221

runlog Convert Model Metadata to Various Formats

Description

Metadata from successful model runs, e.g. NONMEM, comes in various formats, some of which areversion dependent. NONMEM6 and 7 outputs are interconverted with support for the conventionalrun log format as well as a universal format.

Usage

runlog()unilog()as.runlog.file(file, ...)as.unilog.lst(file, run, tool, ...)as.unilog.pxml(x, run, tool = 'nm7', ...)as.unilog.runlog(x, tool = 'nm6', ...)as.runlog.unilog(x, ...)as.file.runlog(x, file = 'NonmemRunLog.csv', header = FALSE, quote = FALSE, na = '.', ...)

Arguments

x data.frame in runlog or unilog format

file file name for metadata file, e.g. ‘NonmemRunLog.csv’, ‘3.lst’

header whether to include column names in output

quote whether to quote cell contents

na string to represent NA in output

... passed arguments

run name (number) of the model run corresponding to the data

tool the tool that created the metadata: currently ‘nm6’ or ‘nm7’

Details

These functions are not typically needed by the user, since rlog serves as an interface.

Metadata may reside in ‘lst’ files (NONMEM primary output), in ‘NonmemRunLog’ files (cre-ated for NONMEM6 by metrumrg INFN routine) or in ‘ext’ files (NONMEM7 secondary out-put). as.unilog.lst, as.runlog.file, and as.pxml.ext (documented elsewhere) read theseformats. pxml is an internal xml format produced by as.pxml.ext and converted to unilog byas.unilog.pxml.

The runlog format by convention has the columns: prob, moment, min, cov, mvof, p1...pn,and (possibly) run. p1 through pn are (an arbitrary number of) parameters for that run. The othersgive, respectively, the problem statement, a flag to identify relative standard error percent, mini-mization status, covariance status, minimum value of the objective function, and run name (num-ber). The primary values for each variable are given in a single record. Where available, a second

222 runlog

record gives ‘PRSE’, with non-informative entries as necessary. Usually the header is not presentin files.

The unilog format is fully normalized. It has the columns: tool, run, parameter, moment, value.Moment is, for instance, ‘estimate’ or ‘prse’. Typically all cells are filled and meaningful. The valuecolumn is handled as text for maximum compatibility across data types. The term ‘parameter’ isused informally: several items typically captured are not really parameters per se.

Unilog and runlog formats are interconvertible via as.runlog.unilog and as.unilog.runlog.as.file.runlog creates the traditional disk file from the runlog format; writing unilog to disk isleft to conventional strategies.

runlog and unilog return zero-row data.frames with the corresponding formats.

Value

as.file.runlog is used for side effects. All others return data.frame in the runlog or unilog format.

Note

These functions are not vectorized: their first arguments are expected to represent a single modelrun.

As of 5.18, as.unilog.run tries to give a more meaningful value of ’min’ than just 1 or 0 for NON-MEM 7. Not supported on NONMEM 7.1.2, since it requires the .xml file available under 7.2.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.unilog.run

• rlog

• as.pxml.ext

Examples

runlog()unilog()ext <- c('TABLE NO. 1: First Order: Goal Function=MINIMUM VALUE OF OBJECTIVE FUNCTION',' ITERATION THETA1 THETA2 THETA3 SIGMA(1,1) OMEGA(1,1) OBJ',' 0 1.70E+0 1.02E-1 2.90E+1 0.00E+0 1.17E+0 11.570086639848398',' 2 1.78E+0 1.06E-1 3.05E+1 0.00E+0 1.08E+0 9.377909428896904',' 4 1.91E+0 1.05E-1 3.14E+1 0.00E+0 8.96E-1 8.983605357031118',' 6 1.94E+0 1.01E-1 3.20E+1 0.00E+0 9.06E-1 8.940731060922468',' 8 1.93E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940110966224346',' 10 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',

runNonmem 223

' 11 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',' -1000000000 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',' -1000000001 6.28E-1 7.36E-3 1.25E+0 0.00E+0 5.44E-1 0.')file <- textConnection(ext)pxml <- as.pxml.ext(file)close(file)pxmlunip <- as.unilog.pxml(pxml,run=3)uniprunlogfile <- c('1001 2 compartment base,, 0, 1, 0.1439E+5, 0.2E+1, 0.4E+1, 0.2E+1, 0.5E+1,0.1E+1, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.1E+0, 0.0E+0, 0.0E+0,0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0, 0.0E+0,0.0E+0, 0.0E+0, 0.0E+0, 0.3E+0, 0.1E+1, 0.0E+0, 0.0E+0, ,','1001 2 compartment base,RSE,,,,0,0,0,0,0,0,0,0,0,0, 0.0E+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0.0E+0, 0.0E+0,0,0, ,')runlogfile <- sub('\n','',runlogfile)file <- textConnection(runlogfile)rlg <- as.runlog.file(file)close(file)rlgas.runlog.unilog(unip)as.unilog.runlog(rlg)

runNonmem Process a Request for NONMEM Invocation

Description

The heart of NONR, this function handles file-level details and dispatches the other major functions,especially runCommand and PLOTR.

Usage

runNonmem(run,...,command,project,wait,checkrunno,diag,fdata,epilog,dvname,logtrans,grp,

224 runNonmem

grpnames,cont.cov,cat.cov,par.list,eta.list,missing,invisible,checksum,grid,nice,udef,compile,execute,split,plotfile=plotfilename(run,project,grp),rundir = filename(project,run),outfile = filename(rundir,run,'.lst'),streams = project,ctlfile = filename(streams,run,'.ctl'),purge=TRUE,sync=if(wait)'y'else'n',interface='nm.pl',perm.cond=NULL,pe=NA)

Arguments

run see NONR

command see NONR

project see NONR

wait see NONR

checkrunno see NONR

diag see NONR

fdata see NONR

epilog see NONR

dvname see NONR

logtrans see NONR

grp see NONR

grpnames see NONR

cont.cov see NONR

cat.cov see NONR

par.list see NONR

eta.list see NONR

runNonmem 225

missing see NONR

invisible see NONR

checksum see NONR

grid see NONR

nice see NONR

udef see NONR

compile see NONR

execute see NONR

split see NONR

plotfile see PLOTR

rundir the directory in which run will occur

outfile see dataSynthesis

streams where to find control streams

ctlfile the original control stream

purge whether to remove files as defined in purgeRunDir

sync whether the R process should wait for the run to complete

interface the name of a function to prepare NONMEM command lines

... extra arguments for other functions

perm.cond passed to PLOTR; defined here to prevent partial matching of pe argument toqsub

pe passed to runCommand

Value

the result of the call to runCommand; or empty string if command is empty string.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• NONR

• dataSynthesis

• runCommand

• purgeRunDir

226 runstate

runstate Detect State of a Run Using File Existence Criteria

Description

In real time, determines the status of a run generated by NONR.

Usage

runstate(run,project=getwd(),rundir=file.path(project,run),testfile=c('FCON','FILE10','INTER'),queued= c(0, 0, 0),compiled= c(1, 0, 0),running= c(1, 1, 1),done= c(NA,0, 1),...)progress(run,project=getwd(),...)follow(run,project=getwd(),interval=10,watch='done',until=length(run),visible=TRUE,...)

Arguments

run a run name or number (scalar)

project path to the directory containing run subdirectories

rundir the path to the run directory

testfile vector of filenames possibly present in rundir

queued logical vector (or coercible); see details

compiled logical vector (or coercible); see details

running logical vector (or coercible); see details

done logical vector (or coercible); see details

interval integer

watch character

until integer

runstate 227

visible logical

... passed to called functions

Details

The status of a run is either queued, compiled, running, done, or indeterminate. The last occurs ifthe run directory does not exist. It also occurs if the more than one or fewer than one of the otherstates is detected. queued, compiled, running, and done must have the same length as testfileand must be coercible to logical. They indicate the subset of testfile that is present in rundirwhen that state applies. Obviously, they should be different from each other.

runstate only analyzes one run at a time, but can be easily wrapped in sapply.

NA in queued, compiled, running, or done indicates not to consider the corresponding file whentesting for this state.

The defaults for testfile are defined by NONMEM. FCON: nm/ABLOCK.f. FILE10: nm/BLKDAT.f.OUTPUT: nm/BEGIN.f. rlog() tests INTER instead of OUTPUT if tool is ’nm7’.

progress tabulates the states for one or more runs. follow prints the progress of one or moreruns if visible = TRUE; if the element specified by watch is less than until, it sleeps intervalseconds and tries again. By default, it updates status at the console until all runs are ’done’. Youmay need to interrupt manually if any are hung.

Value

• runstate: scalar character; one of ‘queued’, ‘compiled’, ‘running’, ‘done’, or ‘indetermi-nate’.

• progress: length 5 integer vector with these names.

• follow: invisible NULL.

Author(s)

Tim Bergsma.

References

http://metrumrg.googlecode.com

See Also

• rlog

Examples

## Not run: metrumrgURL('example/project/script/model.pdf')runstate(1)

228 safeQuote

safe.call Call a Function Safely

Description

Some functions do not accept extra arguments. safe.call passes only those arguments that willbe recognized.

Usage

safe.call(what, ...)

Arguments

what a function

... extra arguments, to be filtered

Value

the result of the called function

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

safeQuote Single-quote Conditionally

Description

Place single quotes around text that contains space and is not already quoted.

Usage

safeQuote(x)

Arguments

x character

setCwres 229

Details

Text is already quoted if it begins with a single or double quote.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• contains

• isSubversionedFile

Examples

safeQuote(c("text","more text",'"already quoted"'))

setCwres Append Conditional Weighted Residuals to an Appropriate File

Description

Appends conditional weighted residuals to an appropriate file.

Usage

setCwres(cwres, file)

Arguments

cwres vector of conditional weighted residuals

file file to append

Value

Used for side effects

Author(s)

Tim Bergsma

230 sets

References

http://metrumrg.googlecode.com

See Also

• PLOTR

sets Binary Operators for Set Relations

Description

These functions test set relations using binary operators. See details.

Usage

## Default S3 method:x %+% y## Default S3 method:x %&% y## Default S3 method:x %-% y## S3 method for class 'keyed'as.vector(x,mode='any')

Arguments

x left operand

y right operand

mode currently ignored

Details

The function %+% and its alias %u% give set union, with obvious mnemonic significance. %&% givesset intersection; mnemonically, elements present in x and y. n looks like an inverted u in manyfonts, so %n% gives set intersection in something more like classical notation. %-% is suggestive ofset difference both in arithmetic and classical notation.

These functions call union, intersect, and setdiff, which coerce their arguments to vector.For convenience, as.vector.keyed is defined to return just the names of a keyed data frame –frequently these are subject to set manipulations.

Value

vector

shuffle 231

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• union

• intersect

• setdiff

Examples

c('a','b','c') %u% c('c','d','e')c('a','b','c') %n% c('c','d','e')c('a','b','c') %-% c('c','d','e')as.vector(as.keyed(Theoph,c('Subject', 'Time')))

shuffle Move the Columns of a Data Frame Relative to Each Other

Description

It can be tedious to reorder the columns in a data.frame. This function lets you move specificcolumns relative to some other named column.

Usage

shuffle(x, who, after = NA)

Arguments

x data.frame

who a character vector of column names to move, or a logical vector of length names(x),or a vector of indices

after the column after which to put who: may be character, integer, NA, or NULL

Details

If after is NA, the named columns are moved to the front (before the first column). If afterhas length zero, or is a number less than zero or an integer greater than the number of remainingcolumns, or is NULL, who is moved to the end. If an integer less than or equal to the number ofremaining columns, who is placed after the corresponding column.

232 simblock

Value

data.frame: a variant of x

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• match

Examples

head(Theoph)head(shuffle(Theoph,'Time'))

simblock Generate Random Effect Deviates for Simulation

Description

Generate random effect values given the number of simulations, degrees of freedom, and a variance-covariance matrix (block).

Usage

simblock(n, df, cov)

Arguments

n the number of simulations that will be performed

df vector of degrees of freedom of block elements

cov variance-covariance matrix

Details

df and cov should have the same length.

Value

matrix, with one row per simulation and one column per element in the corresponding triangularversion of cov.

simpar 233

Author(s)

written by Leonid Gibiansky; modified by Tim Bergsma.

References

http://metrumrg.googlecode.com

See Also

• simpar

simpar Create Parameters for Simulation with Uncertainty

Description

Given the parameter estimates of a mixed effect model, this function generates sets of parametersfor simulation. Each set takes into account the relevant variance-covariance structure of the fixedeffects and random effects. Two levels of random effects are supported, following the namingconventions of NONMEM.

Usage

simpar(nsim,theta,covar,omega,sigma,odf = NULL,sdf = NULL,digits = 4,min = -Inf,max = Inf)

Arguments

nsim scalar numeric specifying the number of sets to attempt

theta vector of point estimates of fixed effect parameters

covar variance-covariance matrix for fixed effect parameters

omega list of variance-covariance matrices for first level random effects

sigma list of variance-covariance matrices for second level random effects

odf vector of omega degrees of freedom, one per matrix

sdf vector of sigma degrees of freedom, one per matrix

234 simpar

digits number of significant digits to include in output

min lower limit for parameter estimates

max upper limit for parameter estimates

Details

If min or max are non-default (see below), you may want to set nsim marginally higher to allow fordropped sets.

covar is coerced to matrix using as.matrix.

If omega and sigma are not lists, they are coerced using list. Then each element is coerced usingas.matrix.

By default, each element in odf and sdf will be the length (number of elements) in the correspond-ing matrix.

min and max may be given as scalar values, in which case they apply to all parameters (as do thedefaults). Alternatively, the first n limits may be specified as a vector, in which case the remaining(if any) will be the default. If any simulated parameter does not fall between its limits, inclusive,the entire parameter set (row) is dropped from the result, with warning.

Value

matrix, with column names indicating parameters, and row names indicating set number beforefiltering by min and max.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com http://www.page-meeting.org/page/page2006/P2006III_11.pdf

See Also

• posmat

• simblock

• as.matrix.halfmatrix

Examples

## Not run: metrumrgURL('example/project/script/simpar.pdf')

set.seed(100)simpar(

nsim=10,theta=c(13,75,1),covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),omega=list(

snap 235

0.1,matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)

),odf=c(50,20),sigma=list(0.04,1),sdf=c(99,99),min=rep(0,3),max=rep(90,3)

)simpar(

nsim=1,theta=c(13,75,1),covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),omega=list(

0.1,matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)

),odf=c(50,20),sigma=list(0.04,1),sdf=c(99,99),min=rep(0,3),max=rep(90,3)

)simpar(

nsim=1,theta=c(13,75,1),covar=matrix(c(10,7,2,7,30,1,2,1,0.5),ncol=3,nrow=3),omega=list(

0.1,matrix(c(0.04,0.02,0.02,0.04),ncol=2,nrow=2)

),odf=c(50,20),sigma=list(0.04,1),sdf=c(99,99),min=Inf,max=-1

)

snap Coerce Values to Nearest of Candidates

Description

For each value in a numeric vector, return the closest match from a vector of candidate values.

Usage

snap(x, rule = 1, left = TRUE, ...)

236 snap

Arguments

x numeric

rule a vector of (finite numeric) candidates, or a single value giving candidate intervalon the real number line

left whether to return the lesser of two equidistant candidates

... ignored

Details

If rule is scalar, it must be positive; a rule will be constructed as a sequence of rule-spaced valuesthat includes zero and includes values at least as extreme as the extremes of x. In some sense,this function is the complement to cut: whereas in cut one specifies the "breaks", with snap onespecifies a set of "attractors" (breaks are the implied midpoints); both functions map their primaryargument to a (possibly) smaller set of values.

Value

numeric

Note

If length of x is zero, it is returned unmodified. If length of rule is zero, value is all NA.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• findInterval

• cut

Examples

snap(c(0.0, 1.0, 1.2, 2.0, 2.9, 3))snap(-10:10, 0.3)xyplot(conc~Time,data=Theoph,groups=Subject)times <- c(0,.25,.5,1,2,4,5,7,9,12,24)xyplot(conc~snap(Time,times),data=Theoph,groups=Subject)snap(c(3,NA,5), c(2,4,6))snap(c(3,NA,5), numeric(0))

sortedInstall 237

sortedInstall Install Local Source Packages Sorted by Dependency

Description

Install packages from a local directory in proper dependency order. Only intended for packages oftype ’source’, i.e. "*.tar.gz".

Usage

sortedInstall(pkgDir = getwd(), libDir=NULL, addLib = TRUE, tmpName = "tmpdir", ...)

Arguments

pkgDir directory where packages (.tar.gz extension) are located

libDir directory where packages are to be installed (if NULL defaults to pkgDir)

addLib logical: add pkgDir to .libPaths?

tmpName temporary file created in pkgDir

... arguments to be passed to install.packages call

Details

This function is an interactive way to recreate a particular package environment, with fine controlover package versions. The user archives the packages locally. The function resolves the interde-pendencies to determine installation order.

Naturally, the metrumrg package and its dependencies must be attached in order to use sortedInstall.If these packages conflict with the contents of pkgDir, users will need detach them before attachingthe desired versions. An easier solution may be closing the current R session and opening a newone.

If pkgDir contains more than one version of a package, the user will be prompted to choose one toinstall.

The user must have write privileges to pkgDir.

The function will destroy tmpName, so if tmpdir exists in pkgDir it should probably be renamed.

Value

Invisible NULL.

Author(s)

Natalie Hsiang

References

http://metrumrg.googlecode.com

238 spaces

See Also

• install.packages

spaces Generate a String of Spaces

Description

Generate a string of spaces.

Usage

spaces(x)

Arguments

x scalar numeric

Details

generates a string of x spaces

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• command

• wrap

Examples

spaces(3)

specfile 239

specfile Determine the Expected Path to a Specification File

Description

If one supplies a run name and project directory, the related control stream can be sought, and thedata file extracted. One expects that the name of any corresponding specification file has the suffix’.spec’ instead of ’.csv’.

Usage

specfile(run,project = getwd(),rundir = filename(project, run),ctlfile = filename(rundir, run, ".ctl"),...)

Arguments

run a run name, as for NONR

project parent of the run directory

rundir path to the run directory

ctlfile name of the control stream

... ignored

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.spec

• NONR

240 specification

specification Create a Data Specification Corresponding to a Particular Data Set

Description

as.spec works with objects that already look like metadata. In contrast, specification drawsup draft metadata, given a candidate. The data.frame method makes the generic call on each of itsmembers before proceeding, thus giving programmers a chance to provide preparatory methods.

Usage

## Default S3 method:specification(x, ...)## S3 method for class 'comment'specification(x, ...)## S3 method for class 'data.frame'specification(x, tol = 10, sep = '/',...)

Arguments

x object of dispatch

tol consider an integer to be factor-like if it has this or fewer unique values.

sep use this separator to encode factor-like objects.

... passed to other functions

Details

specification pre-processes each column, and then proceeds with generic documentation (seeas.spec). It tries to guess among the standard types: character, numeric, integer, datetime, pro-viding range and level information as appropriate. By default, labels are the same as the columnnames, unless the columns have a label attribute. Labels for the levels of factor-like objects (truefactors, and other vectors with few unique values) are by default the same as the values themselves.Units for numerics are not guessed. Typically one refines the resulting spec to more closely specifydata characteristics. It should always be true that x %matches% specification(x).

Value

object with class spec keyed data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

sqrtm 241

See Also

• as.spec

• specfile

• specification

• codes

• encode

• extract

• %matches%

Examples

example(`%matches%`)

sqrtm Help Calculate CWRES

Description

This is a function called by compute.cwres to calculate CWRES.

Usage

sqrtm(x)

Arguments

x a matrix.

See Also

• compute.cwres

242 stableMerge

stableMerge Execute a Stable Left Join

Description

Merge Two Data Sets Without Altering Material from the Left Argument.

Usage

stableMerge(x, y)

Arguments

x the main data.frame

y a second data.frame containing related information

Details

merge is unpredictable, because it can add, drop, and reorder rows, as well as reorder columns andrecreate row names. stableMerge expects a primary data.frame and a secondary data.frame, andperforms a ‘stable’ left join (all.x=TRUE, all.y=FALSE). Absence of extra arguments is by design,for integrity. Keys are defined by common columns, and are repeatable in the primary, but mustbe unique in the secondary data.frame. New columns in the secondary data.frame are appendedto the primary, supplying secondary information by key match. No rows are added, or dropped,row/column order is unaffected, and row names are preserved.

Value

A dataframe with as many rows as nrow(x) but possibly more columns.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• merge

Examples

#a nonsense examplestableMerge(Theoph,BOD)

star 243

star Replace Asterisk in x With y

Description

helper function to dereference ’*’.

Usage

star(x, y)

Arguments

x character

y character

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

static Return the static portion of an object.

Description

Tables can be repetitive for structural reasons. Repetition means, for instance, that a column valueis not changing (i.e., is static) with respect to rows. The data.frame method for static detectswhich columns (maybe all) are static with respect to on; it returns a unique subset of rows for justthose columns. The method for keyed returns by default the columns that are static on the key (i.e.,static with respect to the key). static is conceptually related to constant, which returns a logicalrather than a data subset.

It is possible also to retrieve just the dynamic part of the data set, or both. Currently, the work isdone by lyse.data.frame which returns both and is called in turn by static.data.frame anddynamic.data.frame.

244 static

Usage

## S3 method for class 'data.frame'static(x,on=character(0),strict=TRUE, ...)## S3 method for class 'keyed'static(x,on=key(x),...)## S3 method for class 'data.frame'dynamic(x,on=character(0),strict=TRUE, ...)## S3 method for class 'keyed'dynamic(x,on=key(x),...)## S3 method for class 'data.frame'lyse(x,on=character(0),strict=TRUE, ...)## S3 method for class 'keyed'lyse(x,on=key(x),...)

Arguments

x object of dispatch

on character vector: column names in x

strict boolean: if false, NA’s will be imputed within levels of key using forbak

... ignored

Details

By default, the data.frame method just returns unique rows for columns that are constant acrossthe entire data.frame. If on names columns in x, those columns are retained, and other columnsare retained only if their values are static within combinations of values in the implied key; again,unique rows are returned. By default, the keyed method makes the key explicit; it will be a non-operation if keys are defined and non-duplicated (i.e., all non-key columns are unique and thereforeconstant within the key, so the whole data.frame is returned). In all cases, the result is coerced withas.keyed, using on as the key (even if length zero).

Value

keyed data.frame; for lyse.data.frame, a list with elements static and dynamic.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• constant

• as.keyed

strain 245

Examples

test <- as.keyed(data.frame(SUBJ=c(1,1,1,1,1,2,2,2,2,2),TIME=c(1,2,3,4,5,1,2,3,4,5),MALE=c(1,1,1,1,1,0,0,0,0,0),WT=c(70,70,70,70,70,65,65,65,65,65)),c('SUBJ','TIME'))identical(test,static(test))static(test)static(test,on='SUBJ')

strain Reduce x to Those Elements that Occur in Options

Description

a helper function that filters x on options

Usage

strain(x, options)

Arguments

x character

options character

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

246 summary.nm

summary.nm Analyze an NM Object

Description

These methods test data set features related to use with NONMEM software((c) Icon DevelopmentSolutions). The tests are performed after removing comments.

Usage

## S3 method for class 'nm'naKeys(x, ...)## S3 method for class 'nm'dupKeys(x, ...)## S3 method for class 'nm'badAmt(x, ...)## S3 method for class 'nm'badDv(x, ...)## S3 method for class 'nm'badII(x, ...)## S3 method for class 'nm'falseAmt(x, ...)## S3 method for class 'nm'falseDv(x, ...)## S3 method for class 'nm'noPk(x, ...)## S3 method for class 'nm'predoseDv(x, ...)## S3 method for class 'nm'zeroAmt(x, ...)## S3 method for class 'nm'zeroDv(x, ...)## S3 method for class 'nm'summary(object, by = NULL, ...)## S3 method for class 'nm.summary'print(x, ...)

Arguments

x object of class nm

object object of class nm

by character: column names in object on which to table row counts

... extra arguments, ignored

summary.nm 247

Details

badAmt AMT is NA where EVID is 1

falseAmt AMT defined where EVID is not 1

zeroAmt AMT is zero where EVID is 1

badDv DV is NA where EVID is 0

falseDv DV is defined where EVID is not 0

zeroDv DV is zero where EVID is zero

predoseDv DV is defined before the first record within SUBJ where EVID is 1; NA if no EVID records.

noPk rows where EVID is never 0 within SUBJ

badII II is greater than 0 where ADDL is NA or 0 (unless SS > 0)

summary all of the above, plus some other diagnostics (see value)

print pretty-printing for return value of summary

Value

logical of length nrow(x) unless otherwise stated.

print method used for side effects.

summary method: class nm.summary.

rows nrow(x)

records number of active (non-commented) rows

comments number of commented rows

subjects number of unique ID, active rows

longestCase maximum time range among ID, active rows

naKeys as defined elsewhere, active rows

dupKeys as defined elsewhere, active rows

badDv as defined, active rows

falseDv as defined, active rows

zeroDv as defined, active rows

predoseDv as defined, active rows

badAmt as defined, active rows

falseAmt as defined, active rows

zeroAmt as defined, active rows

noPk as defined, active rows

badII as defined, active rows

table counts of active rows tabled by by, if supplied

Author(s)

Tim Bergsma

248 superset

References

http://metrumrg.googlecode.com

See Also

• as.nm

superset Augment NONMEM Input with Table Output

Description

Given the name of a NONMEM run, create a superset of data that has all of the run input data andany data recoverable from the output of table records.

Usage

superset(run,project = getwd(),rundir = filename(project, run),ctlfile = filename(rundir, run, ".ctl"),key = character(0),read.input = list(read.csv,header = TRUE,as.is = TRUE),read.output = list(read.table,header = TRUE,as.is = TRUE,skip = 1,comment.char = "",check.names = FALSE),exclusive=NULL,digits=5,...)ignored(run,project = getwd(),rundir = filename(project, run),ctlfile = filename(rundir, run, ".ctl"),read.input=list(read.csv,header=TRUE,as.is=TRUE),...)

superset 249

Arguments

run a run name, as for NONR

project parent of the run directory

rundir path to the run directory

ctlfile name of the control stream

key the object model for the input data

read.input a methodology for acquiring the input

read.output a methodology for acquiring the output

exclusive character vector of output column names to exclude; or logical: whether to keepcolumns with re-used names

digits significant digits for assessing informativeness when exclusive=NULL

... ignored

Details

Given a run name and project directory, superset figures out the run directory and location of aNONMEM control stream. It reads the control stream to identify the run-time location of inputand output files, as well as the "ignore" (and/or "accept") criteria that relate extent of input recordsto extent of output records. read.input and read.output are lists consisting of functions andarguments appropriate for reading input and output file formats, respectively. The ignore criteriawill be reconstructed per row so that output can be mapped unambiguously to input. A column withrun as its name is bound to the input data, showing 1 where a record was visible to NONMEM, and0 otherwise.

Normally, superset tries to bind output columns directly to input. Alternatively, if key is provided,it is used as an object model to allow an inferential left join of output onto input; this approach isriskier, but can back fill NA cells with values that are otherwise constant within left-subsets of thekey.

During integration, naming convention of the input is retained, and output column names aremapped by position, using the control stream input criteria. Output tables are restored to inputdimensions using the "ignore" criteria, then checked for length: currently, superset ignores outputtables having fewer rows than the input, as well as output tables whose row count is not a multipleof input row count.

Output tables may contain versions of input columns. Disposition depends on the value of exclusive.If a character vector, it lists columns to exclude from output. If TRUE, all columns with re-usednames will be dropped. If FALSE, such columns will be renamed (*.n, where n is table number).If NULL, only informative columns will be retained and renamed. A column is informative if anyelement is informative. An element is informative if it is newly generated (not NA and not zero, butoriginal is NA) or if it is an alteration (non-NA, and different from non-NA original). If the columnpair can be interpreted as numeric, "different" is determined using only the first digits digits.

Only the first instance of any column among successive output tables is retained.

ignored takes a subset of superset arguments and returns just a logical vector showing which inputrows are dropped. Note that it is possible to invoke either function using just run, just rundir, orjust ctlfile, supplying project as necessary. Normally these three are tightly coordinated andmay be inferred from each other.

250 supp

Value

• superset: data.frame where row count is a multiple of (usually equal to) input row count

• ignored a logical vector indicating which rows were dropped.

Note

In the control stream, avoid use of FIRSTONLY, as this alters the number of rows. Tables createdusing FIRSTONLY can be summarized by superset if key is provided. Note that when key isprovided, innocuous warnings result (e.g. ’nothing to merge’) if items are tabled that are alreadypresent in the original data set.

Early versions of these functions supported the documented ignore/accept syntax, e.g. REP.GT.0.As of v. 5.52, Fortran 95 syntax is also supported, e.g. REP > 0.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• PLOTR

• dataSynthesis

• raised.keyed

supp Merge CDISC Supplemental Data

Description

Generic, with method for data.frame and keyed.

Within CDISC SDTM, data sets SUPPxx have a reasonably fixed relation to their counterparts xx,enabling an automated merge. The method for data.frame defaults to the method for keyed, whichreturns the merge of the two data sets.

Usage

## S3 method for class 'data.frame'supp(x,suppx,

...)

supp 251

## S3 method for class 'keyed'supp(x,suppx,value= 'QVAL', # possibly QORIG or QEVAL

...)

Arguments

x primary CDISC data set

suppx supplemental CDISC data set

value name of column in supplemental set where attribute names are stacked

... ignored

Value

keyed data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com http://www.w3.org/wiki/images/6/61/HCLS$$F2F$$DrugSafety$SDTM_3.1_Implementation_Guide_v1_01.pdf See p. 124.

See Also

• as.keyed

Examples

## Not run:library(foreign)ex <- read.xport('ex.xpt')suppex <- read.xort('suppex.xpt')ex <- supp(ex, suppex)

## End(Not run)

252 svnIsText

svnIsText Check Whether Subversioned Files are Text.

Description

Check whether Subversion considers a file to be text.

Usage

svnIsText(x, ...)

Arguments

x character vector of file names.

... ignored

Details

See http://subversion.apache.org/faq.html#binary-files. When a file is added, Subver-sion guesses whether it is text or binary, storing the decision implicitly as the value (or lack thereof)of the svn:mime-type property. This function makes that decision explicit. Returns NA for files thatare not Subversioned. If you don’t agree with Subversion’s determination, you can alter it manually,or with svnMarkAsText or svnMarkAsNonText.

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• svnMimeType

• svnMarkAsText

• svnMarkAsNonText

svnMarkAsNonText 253

svnMarkAsNonText Mark Subversioned Files as Non-text.

Description

Mark Subversioned files as non-text.

Usage

svnMarkAsNonText(x, ...)

Arguments

x character vector of file names

... ignored

Details

For each Subversioned file in x, the property ‘svn:mime-type’ is set to ‘application/octet-stream’.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversioned

• svnIsText

• svnMarkAsText

• svnPropSet

254 svnMarkAsText

svnMarkAsText Mark Subversioned Files as Text

Description

Mark subversioned files as text, rather than binary.

Usage

svnMarkAsText(x, ...)

Arguments

x character vector of file names

... ignored

Details

For each Subversioned file in x, the property ‘svn:mime-type’ is set to ‘text/’.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversioned

• svnIsText

• svnMarkAsNonText

• svnPropSet

svnMimeType 255

svnMimeType Determine Mime Type for Multiple Files

Description

Determine Subversion mime type for multiple files.

Usage

svnMimeType(x, ...)

Arguments

x character vector of file names

... ignored

Details

Checks the property ‘svn:mime-type’ for subversioned files. NA where file is not subversioned.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• svnPropSet

256 svnPropGet

svnPropGet Get Subversion Property for a Vector of Files

Description

Retrieve a given Subversion property for multiple files.

Usage

svnPropGet(x,prop,...)

Arguments

x character vector of file names

prop a property

... ignored arguments

Details

A vectorized verson of svnPropGetFile.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• svnPropGetFile

svnPropGetFile 257

svnPropGetFile Get Subversion Property for a Single File

Description

Get a subversion property for a single file.

Usage

svnPropGetFile(file, prop)

Arguments

file scalar character file name

prop scalar character property name

Details

Returns NA if file is not subversioned. Returns an empty string if the property is not defined.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversionedFile

258 svnPropSet

svnPropSet Set a Property on a Vector of Subversioned Files

Description

Set a property on multiple files.

Usage

svnPropSet(x, prop, value, ...)

Arguments

x character vector of file names

prop scalar character property name

value scalar character property value

... ignored arguments

Details

This is a vectorized version of svnPropSetFile.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• svnPropSetFile

svnPropSetFile 259

svnPropSetFile Set a Property on a Subversioned File

Description

Set a property on a subversioned file.

Usage

svnPropSetFile(file, prop, value)

Arguments

file scalar character file name

prop scalar character property name

value scalar character property value

Details

It is an error if the file is not subversioned.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• isSubversionedFile

260 svnSetMimeType

svnSetMimeType Set Subversion Mime Type

Description

Set Subversion mime type for multiple files.

Usage

svnSetMimeType(x, type, ...)

Arguments

x character vector

type scalar character

... ignored

Details

Sets Subversion property ‘svn:mime-type’ to type, e.g. ‘/text’ or ‘application/octet-stream’. Just awrapper for svnPropSet.

Value

used for side effects

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• svnPropSet

synthesis 261

synthesis Sequentially Left-join an Arbitrary Number of Data Frames, PickingUp Novel Columns

Description

Integrates specified columns from among a list of data.frames.

Usage

synthesis(x, key = character(0), frames, ...)

Arguments

x A character vector of column names to seek

key column names on which to merge

frames a list of data frames to search

... ignored

Details

For each data.frame, sought columns as well as key columns are preserved, and the result is left-joined to the previous result (if any) after removing duplicate rows.

Value

data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• dataSynthesis

262 tabular.data.frame

tabular.data.frame Convert a Data Frame to a Latex Tabular Environment, Latex Docu-ment, or PDF

Description

The functions tabular, as.document, and as.pdf are generic. Methods are given here that cascadein the order data.frame -> tabular (character) -> document -> pdf. as.document.data.frame isargued identically to tabular, except for a few extra arguments; the function tries to guess the exactlength and width for a page size identical to the printed area (you can modify with the argumentswider and longer). as.pdf.document needs a file stem and (optionally) whether to perform clean-up. The other as.pdf methods are convenience wrappers. as.tabular is an alias for tabular.

tex2pdf accepts the file names of tex fragments. It reads those fragments, wraps them like docu-ments and makes pdf files. viewtex goes one step further, and tries to open those pdfs for viewing.

Usage

## S3 method for class 'data.frame'tabular(x,rules = c(2, 1, 1),walls = 0,grid = FALSE,rowgroups = rownames(x),colgroups = names(x),rowbreaks = if (grid) breaks(rowgroups, ...) else 0,colbreaks = if (grid) breaks(colgroups, ...) else 0,rowcolors=NULL,charjust = "left",numjust = "right",justify = ifelse(sapply(x, is.numeric), numjust, charjust),colwidth = NA,paralign = "top",na = "",verbatim = ifelse(sapply(x, is.numeric), TRUE, FALSE),escape = "#",trim = TRUE,source=NULL,file=NULL,source.label='source: ',file.label='file: ',basefile=FALSE,tabularEnvironment='tabular',...)## S3 method for class 'data.frame'

tabular.data.frame 263

as.document(x,rules = c(2, 1, 1),walls = 0,grid = FALSE,rowgroups = rownames(x),colgroups = names(x),rowbreaks = if (grid) breaks(rowgroups, ...) else 0,colbreaks = if (grid) breaks(colgroups, ...) else 0,rowcolors=NULL,charjust = "left",numjust = "right",justify = ifelse(sapply(x, is.numeric), numjust, charjust),colwidth = NA,paralign = "top",na = "",verbatim = ifelse(sapply(x, is.numeric), TRUE, FALSE),escape = "#",trim = TRUE,wider=0,longer=0,...

)## S3 method for class 'character'as.document(x,preamble=makePreamble(...),thispagestyle=command('thispagestyle',args='empty'),pagestyle=command('pagestyle',args='empty'),prolog=NULL,epilog=NULL,...)

## S3 method for class 'document'as.pdf(x,stem,dir='.',clean=TRUE,...)## S3 method for class 'character'as.pdf(x,stem,...)## S3 method for class 'data.frame'as.pdf(x,stem,...)makePreamble(landscape=FALSE,wide=if(landscape) 279.4 else 215.9,long=if(landscape) 215.9 else 279.4,geoLeft = '1mm',geoRight = '1mm',geoTop = '1mm',geoBottom = '1mm',

264 tabular.data.frame

documentclass = command('documentclass',args='article'),xcolorPackage = command(

'usepackage',options=list('usenames','dvispnames','svgnames','table'),args='xcolor'

),geometryPackage = command('usepackage',options=list(left=geoLeft,top=geoTop,bottom=geoBottom,right=geoRight

),args='geometry'

),geometry = command(

'geometry',args=list(glue('papersize=',glue('{',wide,'mm',',',long,'mm}')

))

),morePreamble = NULL,...)tex2pdf(x,stem=NULL,dir=NULL,clean=TRUE,onefile=FALSE,...)viewtex(x,delete=TRUE,latency=1,...)

Arguments

x object to be converted, typically data.frame (paths of tex files for tex2pdf andviewtex)

rules numeric; will be recycled to length 3. indicates number of horizontal lines aboveand below the header, and below the last row.

walls numeric, recycled to length 2. Number of vertical lines on left and right of table.

grid logical, whether to have lines between rows and columns

rowgroups a vector as long as nrow(x), non-repeats trigger horizontal lines

tabular.data.frame 265

colgroups a vector as long as names(x), non-repeats trigger vertical lines

rowbreaks numeric: a manual way to specify numbers of lines between rows (ignores gridand rowgroups)

colbreaks numeric: a manual way to specify numbers of lines between columns (ignoresgrid and colgroups)

rowcolors character vector of color names, recycled as necessary to color all rows (NULL:no color)

charjust default justification for character columns

numjust default justification for numeric columns

justify manual specification of column justifications: left, right, center, or decimal (vec-tor as long as ncol(x))

colwidth manual specification of column width. (vector of length nrow(x).) Overridesjustify where not NA.

paralign used with colwidth to align paragraphs: top, middle, or bottom.

na string to replace NA elements

verbatim whether to use verbatim environment for numeric fields. Makes sense for deci-mal justification; interacts with trim and justify.

escape symbol used by ‘verb’ command as delimiter. A warning is issued if it is foundin non-NA text.

trim passed to the format command: true by default, so that alignment is the respon-sibility of just the tabular environment arguments

source optional source attribution

file optional file name

source.label optional text to preceed source if specified

file.label optional text to preceed file if specified

basefile if TRUE, strip path from file for display purposestabularEnvironment

default tabular; consider also longtable

wide document width in mm

long document lenth in mm

wider additional document width in mm

longer additional document lenth in mm

preamble latex markup to include before beginning the document

landscape if TRUE, default orientation is ‘landscape’ not ‘portrait’

geoLeft geometry package: left margin

geoRight geometry package: right margin

geoTop geometry package: top margin

geoBottom geometry package: bottom margin

documentclass document class command

266 tabular.data.frame

xcolorPackage xcolor package commandgeometryPackage

geometry package command

geometry geometry specification

morePreamble additional preamble before beginning the document

thispagestyle thispagestyle command

pagestyle pagestyle command

prolog latex markup to include before x

epilog latex markup to include after x

stem the stem of a file name (no extension)

dir output directory

clean whether to delete system files after pdf creation

onefile whether to combine tex snippets into a single file

delete whether temporary pdf (_doc.pdf) should persist

latency how many seconds to wait before deleting temporary pdf

... passed to called functions

Details

Principal choices in tabular.data.frame are the number of lines above and below the header,number of lines at the end of the table (rules), and whether to have lines between rows and columns(grid). If you do want the latter, you can modify their placement easily with rowgroups and col-groups: factor-like objects that show implicitly which sets of columns or rows go together. Neigh-boring groups will be separated with a line. For multiple lines at a given position, explicit controlis offered by rowbreaks and colbreaks. These latter have lengths one less than their respectivedimensions.

If source and source.label are defined, they will be printed in a tiny font immediately underthe table (bound to the tabular element). If file and file.label are defined as well, they will beprinted (tiny) under source. Set source.label to NULL to suppress embedding of source; set toempty string to suppress source label. Set file.label to NULL to suppress embedding of file;set to empty string to suppress file label. Note that file controls file destination, whether or notrepresented in the result.

Rownames are ignored. If informative, capture them as a column.

Converting a tabular object or any character vector to a document causes inclusion of defaultvalues for the the arguments of makePreamble and as.document.character. Any of these canbe dropped by passing NULL. Invocation of makePreamble can be avoided entirely by passing avalue for preamble. Alternatively, specify morePreamble to extend the preamble, or to replace anyelements you may have dropped.

Value

character

tabularformat 267

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• align.decimal

• breaks

• row2tabular

• tabularformat

• wrap

Examples

tabular(head(Theoph))as.tabular(head(Theoph))as.document(head(Theoph))## Not run: as.pdf(head(Theoph),stem='theoph')## Not run: metrumrgURL('example/tabular/tabular.pdf')

tabularformat Create the Format String for Latex Tabular Environment

Description

Create the format string for latex tabular environment.

Usage

tabularformat(justify, breaks, walls)

Arguments

justify character vector of latex alignment symbols

breaks numeric vector: number of vertical dividers at each column break

walls number of vertical lines for left and right edge of table

Details

Used to set column alignment and aesthetics.

Value

character

268 tagvalue

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• tabular.data.frame

tagvalue Convert List to Tag and Value Format

Description

Convert a list to tag and value format.

Usage

tagvalue(x, sep = "=", collapse = ",", ...)

Arguments

x list

sep the symbol to associate tags and values

collapse the character to concatenated tag-value pairs

... ignored

Details

List names, where present, prefix list values, with the indicated separator.

Value

Character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• latex.options

text2decimal 269

Examples

tagvalue(list(a=1,b=2,3))

text2decimal Convert Mixed Text to Decimal

Description

Convert character to numeric value where possible.

Usage

text2decimal(x)

Arguments

x character

Details

x is coerced to character. Leading/trailing text is dropped; and the result is coerced to numeric.Useful, e.g., where measurements are reported with units.

Leading text consists of characters not among 0:9, +,-, or .. The numeric region, if any, is the firstconsecutive string of those characters, and may also include e or E. Any remaining characters areconsidered trailing. Elements are substituted with their numeric regions, and the result is passed toas.numeric.

Changes were made as of version 5.9 to support scientific notation. Note that ’e3’ and ’3e’ bothgive 3: the first has ’e’ stripped before coercion, and the second is valid syntax (e.g., as.numeric(’3e’)).Due to a bugfix in version 5.15, "3X" (where X is a capital letter, or ’a’,’b’,’c’,’d’) now returns 3 notNA.

Value

numeric

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

270 timepoint

Examples

text2decimal('every 3.5 hours')text2decimal('-17 units')x <- c(

'I have -0.3 apples.','I have -3 apples.','I have 3. apples.','I have +3 apples.','3','I have 3','3 apples.','I have e3 apples.','I have 3e apples.','I have +.3 apples.','I have .3 apples.','I have 0.3 apples.','I have 1e3 apples.','I have -1e-3 apples.','I have 1E3 apples.','I have 30e10 apples.','I have 30 + apples.','I have 3G apples.','I have 30+ apples.','I have ++.3 apples.','I have +e3 apples.','I have .3.2 apples.','I have no apples.'

)suppressWarnings(data.frame(x=x,as.decimal=text2decimal(x))) # last 5 are NA

timepoint Temporal Classes with Selective Defaults

Description

timepoint is an abstract superclass of mTime, mDate, and mDateTime. These latter are convenienceclasses that store timepoint information as seconds since the start of 1970-01-01. They rely onPOSIXlt and POSIXct, giving full access to the format constructs of strftime. However, the con-cepts of ‘origin’ and ‘timezone’ are deconstructed (fixed to 1970-01-01 and GMT). Default formatsare suitably chosen for inputs (as.character methods) and outputs (format methods) and may beoverridden. By default, format will append a ‘+’ symbol to timepoints with dangling seconds (notmultiples of 60): seconds are not displayed by default but still operate (perhaps dangerously) incomparisons.

Usage

as.mTime(x, ...)## S3 method for class 'character'as.mTime(x, format = '%H:%M',...)

timepoint 271

## S3 method for class 'numeric'as.mTime(x,...)## S3 method for class 'mTime'as.mTime(x, ...)## S3 method for class 'times'as.mTime(x, ...)as.mDate(x, ...)## S3 method for class 'character'as.mDate(x, format = '%Y-%m-%d',...)## S3 method for class 'numeric'as.mDate(x,...)## S3 method for class 'Date'as.mDate(x,...)## S3 method for class 'mDate'as.mDate(x,...)## S3 method for class 'dates'as.mDate(x,...)as.mDateTime(x, ...)## S3 method for class 'character'as.mDateTime(x, format = '%Y-%m-%d %H:%M',...)## S3 method for class 'numeric'as.mDateTime(x,...)## S3 method for class 'mDate'as.mDateTime(x, y = 0,...)## S3 method for class 'mDateTime'as.mDateTime(x, ...)## S3 method for class 'POSIXct'as.mDateTime(x, ...)## S3 method for class 'POSIXlt'as.mDateTime(x, ...)## S3 method for class 'chron'as.mDateTime(x, ...)## S3 method for class 'mTime'format(x, format = '%H:%M', mark=TRUE,...)## S3 method for class 'mDate'format(x, format = '%Y-%m-%d', mark=TRUE,...)## S3 method for class 'mDateTime'format(x, format = '%Y-%m-%d %H:%M', mark=TRUE,...)## S3 method for class 'timepoint'unique(x, incomparables=FALSE,...)## S3 method for class 'timepoint'Summary(..., na.rm=FALSE)## S3 method for class 'timepoint'xtfrm(x,...)

Arguments

x character time as per format, numeric seconds since 1970-01-01, or timepointsubclass

272 timepoint

... other arguments, usually ignored

y optional time for constructing mDateTime from mDate: anything coercible withas.second()

format character, as per strftime

mark boolean: mark times with dangling seconds using ‘+’

incomparables passed to unique

na.rm passed to Summary

Details

Creating a timepoint object with these methods ultimately calls one of the .numeric methods, eachof which round their first argument to zero places. This means that all comparisons are based onwhole numbers, and therefore not subject to rounding errors.

Seconds that are not multiples of 60 can be stored in mTime and mDateTime objects, but will notbe displayed by default (see above). mDate can only store numbers of seconds that correspond tomidnight. To add time, explicitly create an mDateTime object using as.mDateTime.mDate.

The timepoint classes are all subclasses of numeric, so numeric operations are generally available.

The timepoint classes support NA, Inf, -Inf, as.data.frame, seq, subset, element selection, ele-ment assignment, and interconversion.

The timepoint classes are also subclasses timeline, which exists to support addition and subtrac-tion of durations and timepoints. See examples.

• You cannot add two timepoints.

• You cannot subtract a timepoint from a non-timepoint.

• For the difference of two timepoints, the arguments and result are coerced with as.second.

• When one argument is a timepoint, the other is coerced using as.second, and the result is thetimepoint class.

• For two durations, the second value is coerced to the class of the first, with a message, ifnecessary.

• If only one argument is a duration, the other is coerced to that class.

Value

format character

as.mTime object with class c(’mTime’,’timepoint’,’numeric’)

as.mDate object with class c(’mDate’,’timepoint’,’numeric’)

as.mDateTime object with class c(’mDateTime’,’timepoint’,’numeric’)

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

timepoint 273

See Also

• duration

• c.timeline

Examples

#numeric to timepointas.mTime(0)# 00:00as.mTime(1)# 00:00+as.mTime(-1)# 23:59+as.mTime(60)# 00:01as.mTime(-60)# 23:59as.mTime(86400)# 00:00as.mTime(86460)# 00:01as.mDate(0)# 1970-01-01as.mDate(1)# 1970-01-01as.mDate(-1)# 1969-12-31as.mDate(-86400)# 1969-12-31as.mDate(-86401)# 1969-12-30as.mDateTime(0)# 1970-01-01 00:00as.mDateTime(60)# 1970-01-01 00:01as.mDateTime(61)# 1970-01-01 00:01+as.mDateTime(-1)# 1969-12-31 23:59+

#character to timepointas.mTime('00:00')# 00:00as.mTime('23:59')# 23:59as.mTime('23:59:00')# 23:59as.mTime('23:59:01')# 23:59as.mTime('23:59:01',format='%H:%M:%S')# 23:59+as.mTime('24:00')

274 timepoint

# 00:00as.mDate('1970-01-02')# 1970-01-02as.mDate('01/02/1970',format='%m/%d/%Y')# 1970-01-02as.mDateTime('01/02/1970 12:30',format='%m/%d/%Y %H:%M')# 1970-01-02 12:30as.mDateTime('01/02/1970 12:30:15',format='%m/%d/%Y %H:%M:%S')# 1970-01-02 12:30+

#timepoint to numericas.numeric(as.mTime(0))# 0as.numeric(as.mTime(1))# 1as.numeric(as.mTime(-1))# 86399as.numeric(as.mTime(60))# 60as.numeric(as.mTime(-60))# 86340as.numeric(as.mTime(86400))# 0as.numeric(as.mTime(86460))# 60as.numeric(as.mDate(0))# 0as.numeric(as.mDate(1))# 0as.numeric(as.mDate(-1))# -86400as.numeric(as.mDate(-86400))# -86400as.numeric(as.mDate(-86401))# -172800as.numeric(as.mDateTime(0))# 0as.numeric(as.mDateTime(60))# 60as.numeric(as.mDateTime(61))# 61as.numeric(as.mDateTime(-1))# -1as.numeric(as.mTime('00:00'))# 0as.numeric(as.mTime('23:59'))# 86340as.numeric(as.mTime('23:59:00'))# 86340as.numeric(as.mTime('23:59:01'))# 86340as.numeric(as.mTime('23:59:01',format='%H:%M:%S'))# 86341

timepoint 275

as.numeric(as.mTime('24:00'))# 0as.numeric(as.mDate('1970-01-02'))# 86400as.numeric(as.mDate('01/02/1970',format='%m/%d/%Y'))# 86400as.numeric(as.mDateTime('01/02/1970 12:30',format='%m/%d/%Y %H:%M'))# 131400as.numeric(as.mDateTime('01/02/1970 12:30:15',format='%m/%d/%Y %H:%M:%S'))# 131415

#timepoint to characteras.character(as.mTime(0))# '00:00'as.character(as.mDate(0))# '1970-01-01'as.character(as.mDateTime(0))# '1970-01-01 00:00'

#non-default printoutformat(as.mTime(30000),format='%H')# '08'format(as.mDate('1970-01-01'),format='%d%b%y')# '01Jan70'format(as.mDateTime('1970-01-02 23:30'),format='[%d/%m/%y %H:%M:%S]')# '[02/01/70 23:30:00]'format(as.mTime(1))# '00:00+'format(as.mTime(1),mark=FALSE)# '00:00'

#sequenceseq(from=as.mTime('8:00'),to=as.mTime('12:00'))# 08:00 09:00 10:00 11:00 12:00seq(from=as.mDate('2008-01-01'),to=as.mDate('2008-01-04'))# 2008-01-01 2008-01-02 2008-01-03 2008-01-04seq(from=as.mDateTime('2008-01-01 12:00'),to=as.mDateTime('2008-01-04 12:30'))# 2008-01-01 12:00 2008-01-02 12:00 2008-01-03 12:00 2008-01-04 12:00

#interconversionas.mTime(as.mDate('2008-10-14'))# 00:00as.mTime(as.mDateTime('2008-10-14 08:00'))# 08:00as.mDate(as.mTime('23:59'))# 1970-01-01as.mDate(as.mDateTime('2008-10-14 08:00'))# 2008-10-14as.mDateTime(as.mTime(6000000))# 1970-01-01 10:40as.mDateTime(as.mDate('2008-10-14'))# 2008-10-14 00:00as.mDateTime(as.mDate('2008-10-14'),y=as.mTime('00:30'))

276 timepoint

# 2008-10-14 00:30

#intercoversion from other systemsas.mDate(as.Date('1970-01-01'))# 1970-01-01as.mDateTime(as.POSIXct('1970-01-01',tz='GMT'))# 1970-01-01 00:00as.mDateTime(as.POSIXlt('1970-01-01',tz='GMT'))# 1970-01-01 00:00library(chron)as.mTime(times('12:30:00'))# 12:30as.mDate(dates('01/01/1970'))# 1970-01-01as.mDateTime(chron(dates='01/01/1970',times='12:30:00'))# 1970-01-01 12:30as.mDate.sasdate(0)# 1960-01-01as.mTime(as.numeric(NA))# <NA>

#infinityas.mTime(Inf)# Infas.mDate(Inf)# Infas.mDateTime(Inf)# Infas.mTime(-Inf)# -Infas.mDateTime(Inf) + (Inf)# Infas.mDateTime(Inf) + (-Inf)# <NA>

#comparisonas.mTime('08:00') < as.mTime('09:00')# TRUEas.mDate('1970-01-01') > as.mDate('2008-01-01')# FALSEas.mDateTime('1970-01-01 08:00') > as.mDate('1970-01-01')# TRUE

#summarymax(as.mDate(c('1970-01-01','1980-01-01','1975-01-01')))# 1980-01-01

#operationsas.mDateTime(0) + as.second(60)# 1970-01-01 00:01as.second(60) + as.mDateTime(0)# 1970-01-01 00:01try(as.mDateTime(60) + as.mDateTime(60))

Tmax 277

# Error in `+.timeline`(as.mDateTime(60), as.mDateTime(60)) :# addition is undefined for two timepointsas.mDateTime(0) + 60# 1970-01-01 00:0160 + as.mDateTime(0)# 1970-01-01 00:01as.minute(1) + as.mDateTime(0)# 1970-01-01 00:01as.mDateTime(0) - as.second(60)# 1969-12-31 23:59as.mDateTime(0) - 60# 1969-12-31 23:59as.mDateTime(60) - as.mDateTime(0)# 60try(as.second(60) - as.mDateTime(60))# Error in `-.timeline`(as.second(60), as.mDateTime(60)) :# subtracting a timepoint from non-timepoint is undefinedtry(60 - as.mDateTime(60))# Error in `-.timeline`(as.second(60), as.mDateTime(60)) :# subtracting a timepoint from non-timepoint is undefinedas.second(10) * 6# 60as.mDateTime(0) * 2 #meaningless, but not prevented# 1970-01-01 00:00

#unary operations-as.mTime(1)# 23:59++as.mTime(1)# 00:00+

#sortingsort(unique(as.mTime(c(180,120,60))))# 00:01 00:02 00:03

Tmax Calculate Tmax

Description

Calculate the Time Associated with the Maximum Concentration for each Subject

Usage

Tmax(data, id = 'ID', dv = 'DV', time = 'TIME')

Arguments

data the name of the R data.frame containing the data to use for the Tmax calculation.

time chronologically ordered time variable present in data

278 Tmin

id variable in data defining subject level data

dv dependent variable used to calculate Tmax present in data

Details

The Tmax function performs the calculation based on the variables id, time, and dv present in theR data object.

Value

One Tmax is returned for each subject.

Author(s)

Leonid Gibiansky

References

http://metrumrg.googlecode.com

Tmin Calculate Tmin

Description

Calculate the Time Associated with the Minimum Concentration for Each Subject

Usage

Tmin(data, id = 'ID', dv = 'DV', time = 'TIME')

Arguments

data the name of the R data.frame containing the data to use for the Tmin calculation.

time chronologically ordered time variable present in data

id variable in data defining subject level data

dv dependent variable used to calculate Tmin present in data

Details

The Tmin function performs the calculation based on the variables id, time, and dv present in theR data object.

Value

One Tmin is returned for each subject

totitle 279

Author(s)

Leonid Gibiansky

References

http://metrumrg.googlecode.com

totitle Convert Text to Title Case

Description

Convert text to title case. I.e., capitalize each word. If strict is TRUE, force subsequent letters ineach word to be lower case.

Usage

totitle(x, strict = FALSE)titleCase(x, strict = TRUE,...)

Arguments

x character

strict Shall non-first letters of words be coerced to lower case?

... ignored

Details

The code for totitle is borrowed from the R help for toupper (capword).

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• toupper

• tolower

280 tweak

Examples

titleCase('THETA1')

tweak Adjust Values

Description

tweak is generic. Methods currently exist for classes init, initList, and nmctl. For the latter, to"tweak" a control stream means to jitter the initial estimates. By default, the estimate itself is scaledby a value drawn at random from a normal distribution centered at 1 with standard deviation sd.The default of 0.13 gives about +/- 10 percent change, on average.

Usage

## S3 method for class 'init'tweak(x,sd=0.13,digits=3,...)## S3 method for class 'initList'tweak(x,sd=0.13,digits=3,...)## S3 method for class 'nmctl'tweak(x,sd=0.13,digits=3,...)

Arguments

x object of interest

sd passed to rnorm

digits passed to signif

... passed to other functions

Details

If the tweaked value exceeds one of the bounds, another draw is taken by recursion. To clear allbounds, set fixed to TRUE and then FALSE successively.

Value

object of class init, or a numbered set of these, having class initList.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

variants 281

See Also

• as.nmctl

Examples

path <- system.file('example/project/nonmem/ctl/1005.ctl',package='metrumrg')ctl <- read.nmctl(path,parse=TRUE)ctl$theta[] <- lapply(ctl$theta,`comment<-`,value=NULL)set.seed(0)tweak(ctl$theta)x <- as.initList('(0,3) 2 FIXED (0 .6 1) 10 (-INF,-2.7,0) (37 FIXED) ')xfixed(x)fixed(x) <- TRUEfixed(x) <- FALSEtweak(x)

variants Locate Variants of a File in Distinctive Subdirectories

Description

Give the paths to identically named files distinguished by enclosing subdirectories, themselves en-closed by a directory bearing the file name.

Usage

variants(x, path)

Arguments

x a vector of file names

path a directory enclosing subdirectories bearing the name(s) in x

Details

Consider a file tree where identically named variants of a file are stored in distinguishing subdirec-tories, e.g. directories whose names contain timestamps. The enclosing directory itself bears thesame name as the file in question. Thus, one variant of the file may be located at path/file/var1/fileand a second at path/file/var2/file. Given file (x) and path, variants returns both of these. If x isof length greater than one, all variants are concatenated into a single character vector.

Value

character

Author(s)

Tim Bergsma

282 wikiparse

References

http://metrumrg.googlecode.com

See Also

• latest

wikiparse Parse Wikimath

Description

Parse wikimath, optionally overriding default style arguments.

Usage

wikiparse(x,sim = "~",dot = "*",pregreek = "",sup = "^",openSup = "{",closeSup = "}",sub = "_",openSub = "{",closeSub = "}",wrap = "",...)wiki2latex(x,sim='\\\\sim',dot='\\\\cdot',pregreek = '\\\\',wrap=c('$\\mathrm{','}$'),...)wiki2plotmath(x,sim='%~~%',dot='%.%',sub='',openSub='[',closeSub=']',...)

wikiparse 283

wiki2label(x,...)wiki2parameter(x,...)

Arguments

x character

sim replaces wikimath tilde

dot replaces wikimath asterisk

pregreek prefixes theta, omega, sigma, eta

sup invokes superscript

openSup begins superscript content

closeSup ends superscript content

sub invokes subscript

openSub begins subscript content

closeSub ends subscript content

wrap wraps entire string

... ignored

Details

Wikimath is a text coding convention for simple model statements of the form "V_c /F (L * h^-1 ) ~theta_1 *(WT/70)^theta_2".The functions wiki2latex and wiki2plotmath are wrappers for wikiparse that intend to givenearly identical visual representations in latex and plotmath contexts, respectively. The functionswiki2label and wiki2parameter are extraction functions that give, e.g., “V_c/F” and “THETA1”.

The point of a wikimath statement is to express a mathematical model definition for a quantity ofinterest, usually in terms of a parameter. Generally, a representation of the quantity is to the left of atilde, optionally with units in parentheses. To the right of the tilde is a submodel including relevantparameters and constants. Parameters are limited to theta, omega, sigma, and eta, which should besubscripted. The subscript operator in wikimath is the underscore. The superscript operator is the"hat". Arithmetic operators generally represent themselves.

Subscripts and superscripts may be nested to somewhat arbitrary depth. However, to avoid ambi-guity, nested levels must be terminated explicitly by means of a space character. Thus “V_c /F” isdifferent from “V_c/F ”: in the latter, “/F” is erroneously part of the subscript.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

284 win

See Also

• justUnits

• closers

• wikitab

• tos

• parameter2wiki

Examples

wiki <- "V_c /F (L * h^-1 ) ~theta_1 *(WT/70)^theta_2"wiki2latex(wiki)wiki2plotmath(wiki)wiki2label(wiki)wiki2parameter(wiki)## Not run: metrumrgURL('example/wikimath/wikimath.pdf')

win Identify Windows Platforms

Description

Tells whether the platform OS is of type windows

Usage

win()

Value

logical

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• NONR

Examples

win()

wrap 285

wrap Wrap Text in a Latex Environment

Description

Wrap text in a latex environment.

Usage

wrap(x, environment, options = NULL, args = NULL, depth = 0)

Arguments

x character

environment name of environment

options list or vector

args list or vector

depth integer: extra spaces on the left.

Details

x is wrapped in the specified environment, with options and aruments formatted appropriately.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• command

• latex.args

• latex.options

• spaces

• ltable.data.frame

Examples

wrap('Hello','center')

286 xlog

xlog Extract Indexed Values from XML

Description

For recovered XML values, these functions maintain context by returning data frame columns thatshow the parentage of each value.

Usage

xpath2frame(x,doc,simplify = TRUE,sort = TRUE,nodebase = 'node',namespaces = FALSE,...)

xlog(run,project = getwd(),rundir = filename(project, run),file = filename(rundir, run, ".xml"),xpath = c("/output/nonmem/problem/problem_title","/output/nonmem/problem/estimation/estimation_method","/output/nonmem/problem/estimation/estimation_title","/output/nonmem/problem/estimation/termination_status","/output/nonmem/problem/estimation/final_objective_function","/output/nonmem/problem/estimation/theta/val","/output/nonmem/problem/estimation/omega/row/col","/output/nonmem/problem/estimation/sigma/row/col"),includeFile = NULL,simplify = TRUE,sort = TRUE,nodebase = 'node',namespaces = FALSE,...)

Arguments

x a character vector of xpath expressions; omit namespace specifications if namespacesis FALSE

xlog 287

doc an xml file path, a parsed xml tree, or a character vector to be parsed

simplify whether to simplify the output by dropping static columns and stacking flagcolumns

sort whether to sort the result

nodebase a suggested base name for the stacking column; will be incremented using .nuntil unique

namespaces whether to retain namespaces in parsed documents

run character vector: run names

project NONMEM project directory

rundir character vector of run directories, normally constructed from run names andproject directory

file character vector of xml filenames, normally constructed from run names and rundirectories

xpath character vector of xpath expressions

includeFile xlog drops the column with the file name if it can recover the run name; include-File=TRUE retains file name

... extra arguments, ignored or passed

Details

xmlValue.XMLAttributeValue is defined to support searches for attributes.

A keyed data frame is returned, optionally sorted. The key is all columns except ’value’. Ifsimplify is FALSE, it has columns representing every element of every search path. For xlog,it also has file and run (or file.1, run.1, etc. if these columns were already present).

If simplify is TRUE, columns with only one unique value are dropped. Also, a column namedlike nodebase (e.g. node, or node.1, etc., if node is already present) is introduced. Columns withexactly one unique value other than NA are dropped after placing the column name in correspondingrows of node. Columns beginning with nodebase come first, and therefore have priority whensorting.

By default, namespaces are stripped from parsed XML, and so do not need to be retained in xpathexpressions. Alternatively, specify namespaces=TRUE and include namespaces in xpath expres-sions. See examples.

Value

object with class c(’keyed’,’data.frame’)

Note

As per advice in the XML package: use of absolute xpath expressions may result in faster searches:e.g. "/output/nonmem/problem/problem_title" not "//problem_title".

Author(s)

Tim Bergsma

288 xpath

References

http://metrumrg.googlecode.com

See Also

• xpathSApply

• xpath

• as.keyed

Examples

xpath2frame('/nm:output/nm:nonmem/nm:problem/nm:estimation/nm:monitor/nm:obj',system.file('example/project/nonmem/1005/1005.xml',package='metrumrg'),namespaces = TRUE

)libxmlVersion()## Not run:# libxml 2.8 (others?) may be problematic. You can switch to full path notation# as above, and use 'namespaces=TRUE' (not the default).x <- xpath2frame(

c('/output/nonmem/problem/estimation/monitor/obj/@iteration','/output/nonmem/problem/estimation/monitor/obj'

),system.file('example/project/nonmem/1005/1005.xml',package='metrumrg')

)xcast(x,obj~node)

xpath2frame(c('/output/nonmem/problem/estimation/theta/val','/output/nonmem/problem/estimation/omega/row/col','/output/nonmem/problem/estimation/sigma/row/col'

),system.file('example/project/nonmem/1005/1005.xml',package='metrumrg')

)project <- system.file('example/project/nonmem',package='metrumrg')xlog(1005:1006,project = project)

## End(Not run)

xpath Extract Value of an xpath Expression from and XML File

xpath 289

Description

Given an xpath expression, find corresponding values in an XML tree stored as a file.

Usage

xpath(x,file)

Arguments

x a valid xpath expression

file (path and) name of a file

Details

This relies on the XML package. Somewhat experimental.

Value

same as xpathSApply

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• xpathSApply

Examples

filename <- 'example/project/nonmem/1005/1005.xml'xpath('//nm:theta/nm:val', system.file(filename,package='metrumrg'))xpath('//nm:monitor/nm:obj', system.file(filename,package='metrumrg'))xpath('//nm:covariance/nm:row', system.file(filename,package='metrumrg'))

290 xyplotExt

xyplotExt Plot the Parameter Search History for a NONMEM 7 Run

Description

NONMEM7 produces, for run n, the file n.ext, containing the values of parameter estimates atspecified iterations. Terminal estimates are included, and possibly standard errrors. This functionplots the parameter estimates vs. iteration. 95 percent CI is plotted if standard errors are available.Terminal estimate is indicated.

Usage

xyplotExt(x,data = read.table(file, skip = 1, header = TRUE, check.names = FALSE),project = getwd(),rundir = filename(project, x),file = filename(rundir, x, '.ext'),as.table = TRUE,auto.key = TRUE,layout = c(1, 4),scales = list(relation = 'free'),type = 'l',panel = panel.superpose,panel.groups = function(x,y,group.number,type,...){if (group.number == 3) type <- 'p'panel.xyplot(x = x, y = y, type = type, ...)},...)

Arguments

x run name (number)

data a data.frame representing an *.ext file

project parent of run directory

rundir run directory

file path to .ext file

as.table passed to xyplot

xyplotExt 291

auto.key passed to xyplot

layout passed to xyplot

scales passed to xyplot

type passed to xyplot

panel passed to xyplot

panel.groups passed to xyplot

... passed to xyplot

Details

If data is supplied, x,project,rundir,file are irrelevant. data is reshaped, and passed toxyplot with remaining arguments, all of which may be overridden.

Value

a trellis object

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

• as.pxml.ext

Examples

ext <- c('TABLE NO. 1: First Order: Goal Function=MINIMUM VALUE OF OBJECTIVE FUNCTION',' ITERATION THETA1 THETA2 THETA3 SIGMA(1,1) OMEGA(1,1) OBJ',' 0 1.70E+0 1.02E-1 2.90E+1 0.00E+0 1.17E+0 11.570086639848398',' 2 1.78E+0 1.06E-1 3.05E+1 0.00E+0 1.08E+0 9.377909428896904',' 4 1.91E+0 1.05E-1 3.14E+1 0.00E+0 8.96E-1 8.983605357031118',' 6 1.94E+0 1.01E-1 3.20E+1 0.00E+0 9.06E-1 8.940731060922468',' 8 1.93E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940110966224346',' 10 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',' 11 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',' -1000000000 1.94E+0 1.01E-1 3.20E+1 0.00E+0 8.99E-1 8.940101673144566',' -1000000001 6.28E-1 7.36E-3 1.25E+0 0.00E+0 5.44E-1 0.')file <- textConnection(ext)data <- read.table(file, skip = 1, header = TRUE, check.names = FALSE)close(file)xyplotExt(data=data)

Index

∗Topic classeskeyed-class, 144

∗Topic manipaccept, 7acceptance, 8addl, 9align.decimal, 11as.best.default, 12as.comment, 13as.data.frame.block, 15as.flag, 16as.init, 17as.keyed, 20as.nm, 22as.nmctl, 25as.pxml.ext, 27as.second, 29as.spec, 30as.unilog.run, 32as.xml, 33attribute, 35AUC, 36aug, 37backtrans, 38bin, 38bounds, 40bracket, 41breaks, 42bundleRead, 43c.timeline, 44cast-methods, 47check.subjects, 48CLNR, 48closers, 49codes, 50colname<-, 52combinations, 53command, 55compileflag, 56

compiler, 57compute.cwres, 58config, 65constant, 66contains, 68convertLines, 69css, 70cv, 71dataFormat, 72dataSynthesis, 74deranged, 76diagnosticPlots, 78digest, 79electronicAppendix, 81encode, 83episcript, 84extract, 85filename, 86findNonmemCommand, 87first, 88fixedwidth, 89fixProblem, 91ftable2data.frame, 93getCovs, 94getCwres, 95getdname, 96getPars, 97getTabs, 97glue, 98groupnames, 99half.matrix, 100hash, 101ibw, 127index, 128inner.data.frame, 131is.alpha, 133is.defined, 134is.diagonal, 135is.latex.token, 136

292

INDEX 293

is.one.nonalpha, 137is.square.matrix, 138isSubversioned, 139isSubversionedFile, 140iterations, 140justUnits, 143latest, 145latex.args, 146latex.options, 147locf, 148lookup, 149ltable.data.frame, 150map, 152matches, 153melt.keyed, 155metaMerge, 157metaSub.character, 158metrumrg-package, 6metrumrgURL, 161monotonic, 162naInContext, 164nasum, 165ncomma, 166nest, 167nix, 168nm.pl, 168nmVersion, 171NONR, 172omegacor, 177Ops.keyed, 179ord.matrix, 182packageCheck, 183panel.densitystrip, 184panel.hist, 188panel.stratify, 190parameter2wiki, 192params, 193parens, 194partab, 195percent, 197plot.nm, 198plotfilename, 199PLOTR, 200pool, 203posmat, 204prev, 204purge.dir, 206purge.files, 207

qstat, 207qsub, 208random, 209reapply, 210resample.data.frame, 212riwish, 215rlog, 215row2tabular, 217runCommand, 218runlog, 221runNonmem, 223runstate, 226safe.call, 228safeQuote, 228setCwres, 229sets, 230shuffle, 231simblock, 232simpar, 233snap, 235sortedInstall, 237spaces, 238specfile, 239specification, 240sqrtm, 241stableMerge, 242star, 243static, 243strain, 245summary.nm, 246superset, 248supp, 250svnIsText, 252svnMarkAsNonText, 253svnMarkAsText, 254svnMimeType, 255svnPropGet, 256svnPropGetFile, 257svnPropSet, 258svnPropSetFile, 259svnSetMimeType, 260synthesis, 261tabular.data.frame, 262tabularformat, 267tagvalue, 268text2decimal, 269timepoint, 270Tmax, 277

294 INDEX

Tmin, 278totitle, 279tweak, 280variants, 281wikiparse, 282win, 284wrap, 285xlog, 286xpath, 288xyplotExt, 290

∗Topic methodscast-methods, 47

∗Topic utilitiesrinvchisq, 214

+.timeline, 105+.timeline (timepoint), 270-.timeline, 105-.timeline (timepoint), 270[.comment, 104[.comment (as.comment), 13[.conditioned, 104[.conditioned (index), 128[.digest, 104[.digest (digest), 79[.flag, 104[.flag (as.flag), 16[.initList, 104[.initList (as.init), 17[.keyed, 104[.keyed (as.keyed), 20[.nmctl, 104[.nmctl (as.nmctl), 25[.timeline, 105[.timeline (c.timeline), 44[.uniKey, 105[.uniKey (as.keyed), 20[<-.timepoint, 105[<-.timepoint (c.timeline), 44[[.comment, 105[[.comment (as.comment), 13[[.flag, 105[[.flag (as.flag), 16[[.nmctl, 105[[.nmctl (as.nmctl), 25[[.timeline, 105[[.timeline (c.timeline), 44[[.uniKey, 105[[.uniKey (as.keyed), 20

$.init, 105$.init (as.init), 17$<-.init, 105$<-.init (as.init), 17%+% (sets), 230%-% (sets), 230%&% (sets), 230%contains% (contains), 68%crossed.on% (constant), 66%crosses% (constant), 66%matches% (matches), 153%n% (sets), 230%nested.in% (constant), 66%nests% (constant), 66%u% (sets), 230%+%, 105%+%.default, 105%-%, 105%-%.default, 105%&%, 105%&%.default, 105%contains%, 105%crossed.on%, 105%crosses%, 105%matches%, 32, 51, 84, 105, 241%matches%.character, 105%matches%.data.frame, 105%matches%.keyed, 105%matches%.spec, 105%n%, 105%nested.in%, 105%nests%, 105%u%, 105, 203

accept, 7, 9, 105, 183acceptance, 8, 8, 105, 183acr, 105acr (css), 70add keyed data to a data.frame safely,

125add named elements to a data.frame or

list, 104add supplemental data to a CDISC data

set, 104addl, 9, 105addl.data.frame, 105addl.default, 105adjust control stream initial

estimates, 122

INDEX 295

administer, 6after, 105after (first), 88aggregate.keyed, 106aggregate.keyed (as.keyed), 20align.decimal, 11, 106, 267analyze NONMEM-style parameter labels,

125and.keyed, 106and.keyed (Ops.keyed), 179apply a function across cells of an

indexed vector, giving anidentically-indexed result,125

as.best, 106as.best (as.best.default), 12as.best.data.frame, 106as.best.default, 12, 106as.best.digest, 106as.best.digest (digest), 79as.character, 13as.character.comment, 106as.character.comment (as.comment), 13as.character.flag, 106as.character.flag (as.flag), 16as.character.init, 106as.character.init (as.init), 17as.character.initList, 106as.character.initList (as.init), 17as.character.nmctl, 106as.character.nmctl (as.nmctl), 25as.character.timepoint, 106as.character.timepoint (c.timeline), 44as.character.uniKey, 106as.character.uniKey (as.keyed), 20as.chartime, 106as.chartime (c.timeline), 44as.chartime.numeric, 106as.comment, 13, 13, 106as.comment.comment, 106as.comment.default, 106as.conditioned, 106as.conditioned (index), 128as.conditioned.digest, 106as.conditioned.isolated, 106as.conditioned.keyed, 106as.csv.filename, 106as.csv.filename (resample.data.frame),

212as.csv.filename.character, 106as.data.frame.block, 15, 106as.data.frame.comment, 106as.data.frame.comment (as.comment), 13as.data.frame.flag, 106as.data.frame.flag (as.flag), 16as.data.frame.keyed (as.keyed), 20as.day, 106as.day (as.second), 29as.day.day, 106as.day.duration, 106as.day.hour, 106as.day.month, 106as.day.numeric, 106as.day.week, 106as.day.year, 106as.digest, 107as.digest (digest), 79as.digest.data.frame, 106as.digest.digest, 107as.digest.keyed, 107as.digest.nm, 107as.document, 107as.document (tabular.data.frame), 262as.document.character, 107as.document.data.frame, 107as.file.runlog, 107as.file.runlog (runlog), 221as.filename, 107as.filename (metaSub.character), 158as.filename.character, 107as.flag, 16, 107as.flag.default, 107as.flag.flag, 107as.halfmatrix, 107as.halfmatrix (half.matrix), 100as.halfmatrix.default, 107as.halfmatrix.halfmatrix, 107as.hour, 107as.hour (as.second), 29as.hour.day, 107as.hour.duration, 107as.hour.hour, 107as.hour.minute, 107as.hour.numeric, 107as.hour.second, 107as.init, 17, 107

296 INDEX

as.init.init, 107as.init.numeric, 107as.initList, 27, 107as.initList (as.init), 17as.initList.character, 107as.initList.initList, 107as.initList.list, 107as.initList.numeric, 107as.isolated, 107as.isolated (index), 128as.isolated.digest, 107as.isolated.isolated, 107as.isolated.keyed, 107as.keyed, 20, 54, 81, 108, 131, 144, 244, 251,

288as.keyed.data.frame, 107as.keyed.nm, 107as.keyed.nm (digest), 79as.list.nmctl, 108as.list.nmctl (as.nmctl), 25as.ltable (ltable.data.frame), 150as.matrix.halfmatrix, 108, 234as.matrix.halfmatrix (half.matrix), 100as.mDate, 13, 108as.mDate (timepoint), 270as.mDate.character, 108as.mDate.Date, 108as.mDate.dates, 108as.mDate.mDate, 108as.mDate.numeric, 108as.mDate.sasdate, 108as.mDateTime, 30, 31, 108as.mDateTime (timepoint), 270as.mDateTime.character, 108as.mDateTime.chron, 108as.mDateTime.mDate, 108as.mDateTime.mDateTime, 108as.mDateTime.numeric, 108as.mDateTime.POSIXct, 108as.mDateTime.POSIXlt, 108as.minute, 108as.minute (as.second), 29as.minute.duration, 108as.minute.hour, 108as.minute.minute, 108as.minute.numeric, 108as.minute.second, 108as.month, 108

as.month (as.second), 29as.month.day, 108as.month.duration, 108as.month.month, 108as.month.numeric, 108as.moot, 108as.moot (deranged), 76as.motif, 108as.motif (index), 128as.motif.digest, 108as.motif.keyed, 108as.motif.motif, 108as.motif.nm, 108as.mTime, 109as.mTime (timepoint), 270as.mTime.character, 108as.mTime.mTime, 108as.mTime.numeric, 109as.mTime.times, 109as.nm, 22, 77, 103, 109, 180, 199, 248as.nm.data.frame, 109as.nmctl, 19, 25, 109, 281as.nmctl.character, 109as.numeric, 13as.numeric.chartime, 109as.numeric.chartime (c.timeline), 44as.pdf, 109as.pdf (tabular.data.frame), 262as.pdf.character, 109as.pdf.data.frame, 109as.pdf.document, 109as.pxml (as.pxml.ext), 27as.pxml.ext, 27, 34, 109, 167, 222, 291as.rigged, 109as.rigged (deranged), 76as.roles, 109as.roles (index), 128as.roles.digest, 109as.roles.keyed, 109as.runlog.file, 109, 217as.runlog.file (runlog), 221as.runlog.unilog, 33, 109as.runlog.unilog (runlog), 221as.second, 29, 109as.second.day, 109as.second.duration, 109as.second.hour, 109as.second.minute, 109

INDEX 297

as.second.numeric, 109as.second.second, 109as.spec, 30, 51, 84, 109, 154, 239–241as.spec.character, 109as.spec.data.frame, 109as.tabular, 109as.tabular (tabular.data.frame), 262as.unilog.lst, 33, 109as.unilog.lst (runlog), 221as.unilog.pxml, 33, 109as.unilog.pxml (runlog), 221as.unilog.run, 32, 109, 217, 222as.unilog.runlog, 109as.unilog.runlog (runlog), 221as.vector, 47as.vector.keyed, 109as.vector.keyed (sets), 230as.vector.spec, 109as.vector.spec (as.spec), 30as.vector.uniKey, 110as.vector.uniKey (as.keyed), 20as.week, 110as.week (as.second), 29as.week.day, 109as.week.duration, 110as.week.numeric, 110as.week.week, 110as.xml, 28, 33, 110as.xml.character, 42, 110as.xml.data.frame, 110, 167as.xml.default, 110as.year, 110as.year (as.second), 29as.year.day, 110as.year.numeric, 110as.year.year, 110assemble an analysis data set, 122assign values in a vector to quantile

bins, 124at, 110at (first), 88attribute, 35, 42, 110AUC, 36, 110auc, 110auc (css), 70aug, 37, 110autolog.pl, 110, 172autolog.pl (nm.pl), 168

ave, 211

backtrans, 38, 110badAmt, 110badAmt (summary.nm), 246badAmt.nm, 110badDv, 110badDv (summary.nm), 246badDv.nm, 110badII, 110badII (summary.nm), 246badII.nm, 110bakfor, 110bakfor (locf), 148before, 110before (first), 88bin, 38, 110, 186binary operators for set relations, 126bmi, 110bmi (ibw), 127bounds, 40, 110bracket, 35, 41, 110, 167breaks, 42, 110, 267browse, 6browseURL, 162bsa, 110bsa (ibw), 127bundleRead, 43, 110

c.comment, 111c.comment (as.comment), 13c.flag, 111c.flag (as.flag), 16c.timeline, 30, 44, 111, 273c.uniKey, 111c.uniKey (as.keyed), 20calculate, 6calculate AUC, 123calculate coefficient of variation for

normal or log-normal data, 124calculate coefficients of variation

for normal or log-normal data,124

calculate confidence intervals, 124calculate normal quantiles at limits

of a probability interval, 124calculate one-compartment model

properties, 123calculate percent, 124

298 INDEX

calculate the NONMEM ADDL data itemfrom explicit dose records, 126

calculate Tmax, 123calculate Tmin, 123calculate various clinical

measurements, e.g., body size,123

cast, 47cast,ANY-method (cast-methods), 47cast,keyed-method, 111cast,keyed-method (cast-methods), 47cast-methods, 47cavg, 111cavg (css), 70check some properties of vectors, 126check whether vector is

nonincreasing, nondecreasing,and/or monotonic, 126

check whether your files aresubversioned, 102

check.subjects, 48, 111clear, 111clear (lookup), 149CLNR, 48, 111closers, 49, 111, 284cmax, 111cmax (css), 70cmin, 111cmin (css), 70codes, 32, 50, 84, 111, 154, 241codes.default, 111codes.spec, 111coerce a vector to either numeric or

character, 126coerce text to title case, 126coerce values to nearest of

candidates, 124collapse levels and labels into simple

strings, 126colname (colname<-), 52colname<-, 52, 111colnames, 53column comparisons for keyed

data.frames, 103combinations, 53, 111command, 55, 111, 146, 147, 238, 285compileflag, 56, 111compiler, 57, 111

compute conditional weighted residualsin NONMEM 6, etc., 122

compute.cwres, 58, 64, 111, 241config, 65, 111constant, 66, 111, 244constant.default, 111contains, 68, 111, 229convert a data.frame for printing with

latex, 125convert a vectorized triangular

matrix of random effects to afull matrix, 125

convert line endings to local format,102

convert mixed text to decimal, 126convert NONMEM control streams to

modifiable objects, 122convert parameter labels to wikimath,

124convert the NONMEM output omega or

sigma covariance matrix tocorrelations, 124

convert wikimath to latex or plotmath,124

convertLines, 69, 111cov2cor, 141, 179covariatePlots, 111, 202covariatePlots (diagnosticPlots), 78covplot, 103covplot (panel.densitystrip), 184crcl, 111crcl (ibw), 127create a draft specification for a

data set, 125create a model parameter table, 124create an FDA-style electronic

appendix from a Subversioneddirectory, 102

create and manipulate comment objects,103

create and manipulate dataspecification objects, 103

create and manipulate flags, 103create and manipulate keyed

data.frames, 103create and manipulate nm objects, 103create date, time, and date-time

objects, 126

INDEX 299

create diagnostic plots for finishedmodel runs, 127

create parameters for simulation withuncertainity, 125

create replicate datasets bystratified sampling withreplacement, 125

CreateParametersForSimulation (simpar),233

crosses, 111crosses (constant), 66css, 70, 111ctl2xml, 111ctl2xml (lookup), 149cut, 39, 236cv, 71cvLognormal, 111cvLognormal (cv), 71cvNormal, 111cvNormal (cv), 71cwresPlots, 111, 202cwresPlots (diagnosticPlots), 78

Data, 103, 104, 122, 123, 125, 126data.frame, 47, 144dataFormat, 72, 75, 111dataSynthesis, 73, 74, 79, 86, 92, 111, 202,

225, 250, 261decodes, 112decodes (codes), 50decodes.default, 112decodes.spec, 112delete certain files from run

directories, 102delete files and directories; log what

was deleted to a text file, 102densityplot, 186deranged, 76, 112deranged.data.frame, 112deranged.keyed, 112determine the status of a run, 122diagnose and visualize static data

relationships, 104diagnose and visualize static

relationships, 123diagnose missingness, 104diagnosticPlots, 75, 78, 112, 202digest, 79, 112, 131dir, 82

distance, 112distance (first), 88divide.keyed, 112divide.keyed (Ops.keyed), 179document acceptance of an R

installation, 102document and enforce data set

properties, 104, 123dupKeys, 112dupKeys (as.keyed), 20dupKeys.default, 112dupKeys.nm, 112dupKeys.nm (summary.nm), 246duration, 273duration (as.second), 29dynamic, 112dynamic (static), 243dynamic.data.frame, 112dynamic.keyed, 112

electronicAppendix, 81, 112embed R output in a script, 102encode, 32, 51, 83, 112, 154, 240, 241encode.character, 112encode.default, 112encode.list, 112encoded, 31, 112encoded (codes), 50encoded.default, 112encoded.spec, 112episcript, 84, 112explicitPath, 112explicitPath (fixProblem), 91extfile, 112extfile (fixProblem), 91extract, 51, 85, 112, 241extract numbered parenthetical

substrings of regularexpressions, 126

extract value of an xpath expressionfrom an xml file, 125

extractPath, 112extractPath (fixProblem), 91

f, 112f (as.flag), 16falseAmt, 112falseAmt (summary.nm), 246falseAmt.nm, 112

300 INDEX

falseDv, 112falseDv (summary.nm), 246falseDv.nm, 112file, 102filename, 86, 112find the static portion of a data

frame, 104findInterval, 236findNonmemCommand, 87, 112, 173first, 88, 113fixed, 113fixed (as.init), 17fixed.init, 113fixed.initList, 113fixed<-, 113fixed<- (as.init), 17fixed<-.init, 113fixed<-.initList, 113fixedwidth, 89, 113fixedwidth.data.frame, 113fixFile, 113fixFile (fixProblem), 91fixProblem, 91, 113follow, 113follow (runstate), 226forbak, 113, 244forbak (locf), 148format a data.frame as fixed-width, 104format.comment, 113format.comment (as.comment), 13format.duration, 113format.duration (as.second), 29format.flag, 113format.flag (as.flag), 16format.init, 113format.init (as.init), 17format.initList, 113format.initList (as.init), 17format.legacy, 113format.legacy (index), 128format.mDate, 113format.mDate (timepoint), 270format.mDateTime, 113format.mDateTime (timepoint), 270format.mTime, 113format.mTime (timepoint), 270format.nmctl, 113format.nmctl (as.nmctl), 25

format.uniKey, 113format.uniKey (as.keyed), 20ftable2data.frame, 93, 113

generate a combined run log frommultiple NONMEM runs, 124

getCovs, 94, 113getCwres, 95, 113getdname, 96, 113getPars, 97, 113getTabs, 97, 113glue, 98, 113, 194groupnames, 99, 113gsub, 160guidetext, 31, 86, 113guidetext (codes), 50guidetext.spec, 114

half, 114half (half.matrix), 100half.matrix, 100, 114, 182handle each level of a stripplot

independently, 127hash, 101, 114head, 210head.digest, 114head.digest (digest), 79helpAdminister, 102helpBrowse, 103helpClasses, 103helpDataFrame, 104helpList, 104helpMatrix, 122helpModel, 122helpPharmacometric, 123helpPrepare, 123, 133helpQuantify, 124helpReport, 124helpSimulate, 125helpStrategic, 125helpVector, 126helpVisualize, 126hidden, 114hidden (as.comment), 13hidden.data.frame, 114hide, 114hide (as.comment), 13hide.data.frame, 114

INDEX 301

ibw, 114, 127identify documented parameter names,

124identify elements within cells that

meet some instance of acondition, 125

ignored, 114ignored (superset), 248impute missing vector values, 126ind.cwres, 114ind.cwres (compute.cwres), 58index, 81, 114, 128index.conditioned, 114index.digest, 114index.isolated, 114index.keyed, 114index.nm, 114init (as.init), 17initList, 25initList (as.init), 17inner, 114inner (inner.data.frame), 131inner.data.frame, 114, 131install local source packages in

dependency order, 102install.packages, 238integrate model input with output, 122integrate model output with input, 122interconvert between square matrices

and triangular matrices, 122interconvert time units, 103, 126intersect, 203, 231investigate pharmacometric properties,

123is.alpha, 114, 133, 137is.cwres.readable.file, 114is.cwres.readable.file (compute.cwres),

58is.defined, 114, 134is.diagonal, 114, 135is.fixed, 114is.fixed (is.diagonal), 135is.iiv, 114is.iiv (is.diagonal), 135is.latex.token, 114, 134, 136, 137is.na, 134, 165is.offdiagonal, 114is.offdiagonal (is.diagonal), 135

is.one.nonalpha, 114, 137, 137is.random, 114is.random (is.diagonal), 135is.residual, 114is.residual (is.diagonal), 135is.square, 114is.square (is.square.matrix), 138is.square.matrix, 114, 138, 182isSubversioned, 114, 139, 140, 253, 254isSubversionedFile, 114, 139, 140, 229,

257, 259isSymmetric.matrix, 101, 138, 182iterations, 114, 140

join or subtract keyed data.frames, 103justUnits, 115, 142, 284

ke, 115ke (css), 70key, 115key (as.keyed), 20key<-, 115key<- (as.keyed), 20keyed-class, 144

labels.spec, 115labels.spec (codes), 50lapply, 44, 211last, 115last (first), 88latest, 115, 145, 282latex.args, 115, 146, 285latex.options, 115, 147, 268, 285lbm, 115lbm (ibw), 127left.keyed, 115left.keyed (Ops.keyed), 179legacy, 115legacy (index), 128legacy<-, 115legacy<- (index), 128lhs, 115lhs (justUnits), 143library, 183list, 6, 144list the iteration statistics in the

NONMEM output, 124locate path-variant versions of a

file, 102

302 INDEX

locf, 115, 148lookup, 115, 149, 194, 197lookup some other form of parameter

names, 124lookup.one, 115lower, 115lower (bounds), 40ltable, 115ltable (ltable.data.frame), 150ltable.data.frame, 56, 115, 150, 285lyse, 115lyse (static), 243lyse.data.frame, 115lyse.keyed, 115

make forest plots of covariateeffects, 127

make multiple, systematicsubstitutions in text files,e.g., control streams, 122, 125

make scatterplots and index plots forstatic members of a data set,127

makePreamble, 115makePreamble (tabular.data.frame), 262manipulate wikimath elements, 124map, 115, 152map one set of values to another, 126match, 89, 153, 232matches, 153maxChar, 115maxChar (prev), 204mDate (timepoint), 270mDateTime (timepoint), 270melt.data.frame, 155melt.keyed, 22, 47, 115, 155merge, 158, 242merge recursively, 123merge.keyed, 115merge.keyed (as.keyed), 20metaMerge, 115, 157metaMerge.character, 115metaMerge.default, 115metaMerge.list, 115metaSub, 115metaSub (metaSub.character), 158metaSub.character, 115, 158, 213metaSub.filename, 115metrumrg, 102–104, 122–127

metrumrg (metrumrg-package), 6metrumrg-package, 6metrumrgURL, 103, 115, 161minus.keyed, 116minus.keyed (Ops.keyed), 179minus.moot, 116minus.moot (deranged), 76model, 6model a control stream for easy

generation of variants, 125monotonic, 116, 162monotonic.default, 116moot, 116moot (deranged), 76moot.nm, 116motif, 116motif (index), 128move columns in a data frame, 104msffile, 116msffile (fixProblem), 91mTime (timepoint), 270

naInContext, 116, 164naKeys, 116naKeys (as.keyed), 20naKeys.default, 116naKeys.nm, 116naKeys.nm (summary.nm), 246name (colname<-), 52name<-, 116name<- (colname<-), 52names, 53, 166nasum, 116, 165ncomma, 116, 166nest, 116, 167nix, 116, 168nm, 116nm (as.nm), 22nm.data-class (compute.cwres), 58nm.pl, 116, 168nmPlots, 116, 117, 170, 199nmVersion, 116, 171nocb, 116nocb (locf), 148nondecreasing, 116nondecreasing (monotonic), 162nondecreasing.default, 116nonincreasing, 116nonincreasing (monotonic), 162

INDEX 303

nonincreasing.default, 116NONR, 87, 103, 116, 168, 172, 200, 202, 225,

239, 249, 284noPk, 116noPk (summary.nm), 246noPk.nm, 116nospace, 116nospace (justUnits), 143not.keyed, 116not.keyed (Ops.keyed), 179noUnits, 116noUnits (justUnits), 143nth, 116nth (first), 88nxt, 116nxt (prev), 204

offdiag, 116, 136offdiag (half.matrix), 100offdiag.halfmatrix, 116oldClass, 144omegacor, 117, 177on.diagonal (is.diagonal), 135only, 117only (first), 88Ops.keyed, 22, 24, 77, 117, 179ord, 117ord (ord.matrix), 182ord.halfmatrix, 117ord.matrix, 101, 117, 138, 182

packageCheck, 8, 9, 117, 183padded, 117padded (align.decimal), 11panel.bar, 117panel.bar (panel.hist), 188panel.covplot, 117, 192panel.covplot (panel.densitystrip), 184panel.cuts, 117panel.cuts (panel.densitystrip), 184panel.densitystrip, 117, 184, 192panel.hist, 117, 188, 192panel.ref, 117panel.ref (panel.densitystrip), 184panel.stratify, 117, 186, 189, 190panel.xyplot, 192parameter2wiki, 117, 192, 284params, 117, 193, 197parens, 117, 194

parfile, 117parfile (fixProblem), 91partab, 103, 117, 194, 195paste, 99percent, 72, 117, 197perform strategic data manipulations,

123plot, 6plot nm objects, 127plot the parameter search history for

a NONMEM7 run, 127plot.conditioned, 117plot.conditioned (index), 128plot.digest, 117plot.digest (index), 128plot.isolated, 117plot.isolated (index), 128plot.keyed, 117plot.keyed (index), 128plot.nm, 117, 171, 198plotfilename, 117, 199PLOTR, 38, 79, 95–99, 117, 174, 176, 200, 200,

228, 230, 243, 245, 250plus.keyed, 117plus.keyed (Ops.keyed), 179plus.rigged, 117plus.rigged (deranged), 76pool, 117, 203posmat, 117, 204, 234predoseDv, 117predoseDv (summary.nm), 246predoseDv.nm, 117prepare, 6prev, 117, 163, 204print.comment, 118print.comment (as.comment), 13print.duration, 118print.duration (as.second), 29print.flag, 118print.flag (as.flag), 16print.halfmatrix, 118print.halfmatrix (half.matrix), 100print.init, 118print.init (as.init), 17print.initList, 118print.initList (as.init), 17print.keyed.summary, 118print.keyed.summary (as.keyed), 20

304 INDEX

print.nm.summary, 118print.nm.summary (summary.nm), 246print.nmctl, 118print.nmctl (as.nmctl), 25print.timepoint, 118print.timepoint (c.timeline), 44print.uniKey, 118print.uniKey (as.keyed), 20progress, 118progress (runstate), 226purge.dir, 118, 206, 207purge.files, 118, 207purgeRunDir, 118, 225purgeRunDir (rlog), 215

qnorm, 41qstat, 118, 207qsub, 118, 208, 208quantile, 39

raised.keyed, 118, 250raised.keyed (Ops.keyed), 179random, 209read data files from a directory into

a list, 102read.cwres.data, 118read.cwres.data (compute.cwres), 58read.nm, 118read.nm (as.nm), 22read.nmctl, 118read.nmctl (as.nmctl), 25read.spec, 118read.spec (as.spec), 30read.table, 15readLines, 70reapply, 10, 118, 210reformat an ftable for printing with

latex, 125regex, 160regexec, 85, 86regexpr, 68rename selected columns, 104render a data.frame to pdf format, 125render file-based tex fragments as pdf

for informal viewing, 125rep, 211rep.comment, 118rep.comment (as.comment), 13rep.flag, 118

rep.flag (as.flag), 16rep.timeline, 118rep.timeline (c.timeline), 44rep.uniKey, 118rep.uniKey (as.keyed), 20report, 6report names as comma-delimited, 102resample, 118resample (resample.data.frame), 212resample.csv.filename, 118resample.data.frame, 118, 212resample.filename, 118resolve, 118resolve (fixProblem), 91rhs, 118rhs (justUnits), 143rig, 118rig (deranged), 76rig.nm, 118rinvchisq, 119, 214riwish, 119, 215rlog, 119, 179, 197, 215, 222, 227rnorm, 280roles, 119roles (index), 128row2tabular, 119, 217, 267run NONMEM and create diagnostic

plots, 122, 125runCommand, 56, 57, 119, 170, 209, 218, 225runhead, 119runhead (prev), 204runlog, 119, 221runNonmem, 65, 85, 92, 119, 171, 173, 175,

176, 206, 220, 223runstate, 119, 217, 226

safe.call, 119, 228safeQuote, 119, 228sample, 213scavenge, 119scavenge (fixProblem), 91seq.default, 45, 46seq.timeline, 119seq.timeline (c.timeline), 44setCwres, 119, 229setdiff, 203, 231sets, 230show sorted unique rows, 104shuffle, 119, 231

INDEX 305

sigmacor, 119sigmacor (omegacor), 177signif, 197, 280simblock, 119, 232, 234simpar, 103, 119, 233, 233simulate, 6sink, 102snap, 119, 235sort.keyed, 119sort.keyed (as.keyed), 20sortedInstall, 237spaces, 56, 119, 238, 285specfile, 32, 51, 84, 119, 154, 239, 241specification, 32, 51, 84, 119, 154, 240, 241specification.comment, 119specification.data.frame, 119specification.default, 119splom.conditioned, 119splom.conditioned (index), 128splom.digest, 119splom.digest (index), 128splom.keyed, 119splom.keyed (index), 128sqrtm, 119, 241stableMerge, 119, 242star, 119, 243static, 81, 119, 131, 243static.data.frame, 119static.keyed, 119, 180strain, 119, 245strftime, 45, 46, 270, 272summarize a table of subject data, 123summary.hidden.data.frame, 120summary.hidden.data.frame (as.comment),

13summary.keyed, 120summary.keyed (as.keyed), 20summary.nm, 24, 120, 246summary.spec, 120summary.spec (as.spec), 30Summary.timepoint, 120Summary.timepoint (timepoint), 270superset, 120, 248supp, 120, 250supp.data.frame, 120supp.keyed, 120svnIsText, 82, 120, 252, 253, 254svnMarkAsNonText, 82, 120, 252, 253, 254

svnMarkAsText, 82, 120, 252, 253, 254svnMimeType, 120, 252, 255svnPropGet, 120, 256svnPropGetFile, 120, 256, 257svnPropSet, 120, 253–255, 258, 260svnPropSetFile, 120, 258, 259svnSetMimeType, 120, 260synthesis, 73, 120, 261system.file, 162

tabfile, 120tabfile (fixProblem), 91table, 39tabular, 103, 120tabular (tabular.data.frame), 262tabular.data.frame, 11, 43, 120, 152, 218,

262, 268tabularformat, 120, 267, 267tagvalue, 120, 147, 268tapply, 211tell Subversion to treat your files as

text, 102test a character vector for occurences

of a pattern, 126test for unique and shared elements

among two vectors, 126test whether data corresponds to some

specification, 102test whether elements are defined, 126test whether Subversion thinks your

files are text, 102tex2pdf, 120tex2pdf (tabular.data.frame), 262text2decimal, 120, 269timeline, 29, 30timeline (timepoint), 270timepoint, 46, 270times.keyed, 120times.keyed (Ops.keyed), 179titleCase, 120, 193titleCase (totitle), 279Tmax, 120, 277tmax, 120tmax (css), 70Tmin, 120, 278tolower, 279tos, 120, 193, 196, 197, 284tos (justUnits), 143totitle, 120, 279

306 INDEX

toupper, 279transform, 37transform.keyed, 120transform.keyed (as.keyed), 20TruncateParametersForSimulation

(simpar), 233tweak, 121, 280tweak.init, 120tweak.initList, 120tweak.nmctl, 121

uniKey, 121uniKey (as.keyed), 20uniKey.keyed, 121unilog, 121unilog (runlog), 221unilogcor, 121unilogcor (omegacor), 177union, 231unique.comment, 121unique.comment (as.comment), 13unique.timepoint, 121unique.timepoint (timepoint), 270unique.uniKey, 121unique.uniKey (as.keyed), 20unitDensity, 121unitDensity (panel.densitystrip), 184unitHist, 121unitHist (panel.hist), 188unsorted, 121unsorted (as.keyed), 20unsorted.keyed, 121upper, 121upper (bounds), 40use classes specialized for data

assembly, 123

variants, 121, 145, 281vector, 144viewtex, 121viewtex (tabular.data.frame), 262visualize model results, 122visualize simulation results, 125

wiki2label, 121wiki2label (wikiparse), 282wiki2latex, 121, 143, 193wiki2latex (wikiparse), 282wiki2parameter, 121, 193

wiki2parameter (wikiparse), 282wiki2plotmath, 121, 143wiki2plotmath (wikiparse), 282wikimath, 103, 192, 197wikimath (wikiparse), 282wikiparse, 50, 121, 143, 282wikitab, 121, 284wikitab (partab), 195win, 121, 284work with data.frames, 123work with matrices, 123work with vectors, 123wrap, 56, 121, 146, 147, 238, 267, 285write, 27write.nm, 121write.nm (as.nm), 22write.nmctl, 121write.nmctl (as.nmctl), 25write.spec, 121write.spec (as.spec), 30write.table, 90writeLines, 70

xlog, 286xmlValue.XMLAttributeValue (xlog), 286xpath, 121, 288, 288xpath2frame (xlog), 286xpathSApply, 288, 289xtfrm.comment, 121xtfrm.comment (as.comment), 13xtfrm.flag, 121xtfrm.flag (as.flag), 16xtfrm.timepoint, 121xtfrm.timepoint (timepoint), 270xtfrm.uniKey, 121xtfrm.uniKey (as.keyed), 20xyplotExt, 28, 121, 290

zeroAmt, 121zeroAmt (summary.nm), 246zeroAmt.nm, 121zeroDv, 121zeroDv (summary.nm), 246zeroDv.nm, 121