R/NMextractText.R
NMextractText.Rd
If you want to extract input sections like $PROBLEM, $DATA etc, see NMreadSection. This function is more general and can be used to extract eg result sections.
NMextractText(
file,
lines,
text,
section,
char.section,
char.end = char.section,
return = "text",
keep.empty = FALSE,
keep.name = TRUE,
keep.comments = TRUE,
as.one = TRUE,
clean.spaces = FALSE,
simplify = TRUE,
match.exactly = TRUE,
type = "mod",
linesep = "\n",
keepEmpty,
keepName,
keepComments,
asOne
)
A file path to read from. Normally a .mod or .lst. See lines and text as well.
Text lines to process. This is an alternative to using the file and text arguments.
Use this argument if the text to process is one long character string, and indicate the line separator with the linesep argument. Use only one of file, lines, and text.
The name of section to extract. Examples: "INPUT", "PK", "TABLE", etc. It can also be result sections like "MINIMIZATION".
The section denoted as a string compatible with regular expressions. "$" (remember to escape properly) for sections in .mod files, "0" for results in .lst files.
A regular expression to capture the end of the section. The default is to look for the next occurrence of char.section.
If "text", plain text lines are returned. If "idx", matching line numbers are returned. "text" is default.
Keep empty lines in output? Default is FALSE. Notice, comments are removed before empty lines are handled if `keep.comments=TRUE`.
Keep the section name in output (say, "$PROBLEM") Default is TRUE. It can only be FALSE, if return="text".
Default is to keep comments. If FALSE, the will be removed.
If multiple hits, concatenate into one. This will most often be relevant with name="TABLE". If FALSE, a list will be returned, each element representing a table. Default is TRUE. So if you want to process the tables separately, you probably want FALSE here.
If TRUE, leading and trailing are removed, and multiplied succeeding white spaces are reduced to single white spaces.
If asOne=FALSE, do you want the result to be simplified if only one table is found? Default is TRUE which is desirable for interactive analysis. For programming, you probably want FALSE.
Default is to search for exact matches of `section`. If FALSE, only the first three characters are macthed. E.G., this allows "ESTIMATION" to match "ESTIMATION" or "EST".
Either mod, res or NULL. mod is for information that is given in .mod (.lst file can be used but results section is disregarded). If NULL, NA or empty string, everything is considered.
If using the text argument, use linesep to indicate how lines should be separated.
Deprecated. See keep.empty.
Deprecated. See keep.name.
Deprecated. See keep.comments.
Deprecated. See as.one.
character vector with extracted lines.
This function is planned to get a more general name and then be called by NMreadSection.
Other Nonmem:
NMapplyFilters()
,
NMgenText()
,
NMreadSection()
,
NMreplaceDataFile()
,
NMwriteSection()
NMreadSection(system.file("examples/nonmem/xgxr001.lst", package = "NMdata"),section="DATA")
#> [1] "$DATA xgxr1.csv IGNORE=@ IGNORE=(FLAG.NE.0)"