write.nonmem.csv | R Documentation |
These convenience functions are simple wrappers to the standard read/write functions that make reading and writing NONMEM data files and tables easier and more consistent.
write.nonmem.csv(x, file, digits = 6, colnames.toupper = TRUE)
read.nonmem.csv(file, colnames.tolower = TRUE)
read.nonmem.table(file, colnames.tolower = TRUE)
x |
A |
file |
A character string naming a file. |
digits |
An integer specifying the number of decimal digits to keep for number variables. |
colnames.toupper |
Should column names be converted to uppercase before writing? |
colnames.tolower |
Should column names be converted to lowercase after reading? |
write.nonmem.csv
calls write.csv
after: (1)
rounding all numeric columns according to digits
; (2)
converting all column names to uppercase
(if colnames.toupper = TRUE
, the default); and (3) pre-pending
'#
' to the name of the first column (so that NONMEM will
ignore the line containing the variable names).
read.nonmem.csv
is for reading NONMEM datasets. It call
read.csv
with na.strings = c(".", "", "NA")
and
then: (1) removing 'X.
' from the name of the first column if
present (by default, R
converts the '#
' prefix to
'X.
'); and (2) converting all column named to lowercase (if
colnames.tolower = TRUE
, the default).
read.nonmem.table
is for reading table files produced by
NONMEM '$TABLE
' statements. These tables typically look something like:
TABLE NO. 1 ID DV MDV ETA1 ETA2 ETA3 ETA4 IPRED CWRES DV PRED RES WRES 1.0001E+04 0.0000E+00 1.0000E+00 -1.3065E-01 -5.8225E-01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 1.0001E+04 0.0000E+00 1.0000E+00 -1.3065E-01 -5.8225E-01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 1.0001E+04 2.5200E+03 0.0000E+00 -1.3065E-01 -5.8225E-01 0.0000E+00 0.0000E+00 1.6347E+03 2.5442E+00 2.5200E+03 5.4237E+02 1.9776E+03 3.5474E+00 1.0001E+04 0.0000E+00 1.0000E+00 -1.3065E-01 -5.8225E-01 0.0000E+00 0.0000E+00 4.1236E+02 0.0000E+00 0.0000E+00 5.3607E+02 0.0000E+00 0.0000E+00 ...
read.nonmem.table
calls read.table
with skip = 1
, header
= TRUE
and na.strings = c(".", "")
before converting all
column named to lowercase (if colnames.tolower = TRUE
, the
default) and changing 'ID
' to a factor (with
asID
.
write.nonmem.csv
is called for its side-effects (returns an
invisible 'NULL
').
read.nonmem.csv
and read.nonmem.table
both return a
data.frame
.
Benjamin Rich <mail@benjaminrich.net>
write.csv
read.csv
read.table
tolower
toupper
asID
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.