NMextractText: Versatile text extractor from Nonmem (input or output)...

Description Usage Arguments Details Value See Also Examples

View source: R/NMextractText.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
NMextractText(
  file,
  lines,
  text,
  section,
  char.section,
  char.end = char.section,
  return = "text",
  keepEmpty = FALSE,
  keepName = TRUE,
  keepComments = TRUE,
  asOne = TRUE,
  simplify = TRUE,
  cleanSpaces = FALSE,
  type = "mod",
  linesep = "\n"
)

Arguments

file

A file path to read from. Normally a .mod or .lst. See lines and text as well.

lines

Text lines to process. This is an alternative to using the file and text arguments.

text

Use this argument if the text to process is one long character string, and indicate the line seperator with the linesep argument. Use only one of file, lines, and text.

section

The name of section to extract. Examples: "INPUT", "PK", "TABLE", etc. It can also be result sections like "MINIMIZATION".

char.section

The section denoter as a string compatible with regular expressions. "\$" for sections in .mod files, "0" for results in .lst files.

char.end

A regular expression to capture the end of the section. The default is to look for the next occurrence of char.section.

return

If "text", plain text lines are returned. If "idx", matching line numbers are returned. "text" is default.

keepEmpty

Keep empty lines in output? Default is FALSE.

keepName

Keep the section name in output (say, "$PROBLEM") Default is TRUE. It can only be FALSE, if return"idx".

keepComments

Keep comment lines?

asOne

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.

simplify

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.

cleanSpaces

If TRUE, leading and trailing are removed, and multiplied succeeding white spaces are reduced to single white spaces.

type

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.

linesep

If using the text argument, use linesep to indicate how lines should be separated.

Details

This function is planned to get a more general name and then be called by NMreadSection.

Value

character vector with extracted lines.

See Also

Other Nonmem: NMapplyFilters(), NMreadSection(), NMwriteData(), NMwriteSection()

Examples

1
NMreadSection(system.file("examples/nonmem/xgxr001.lst", package = "NMdata"),section="DATA")

NMdata documentation built on Aug. 10, 2021, 1:06 a.m.