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

View source: R/NMextractText.R

NMextractTextR Documentation

Versatile text extractor from Nonmem (input or output) control streams

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

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,
  cleanSpaces
)

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 separator 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 denoted as a string compatible with regular expressions. "$" (remember to escape properly) 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.

keep.empty

Keep empty lines in output? Default is FALSE.

keep.name

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

keep.comments

Keep comment lines? This concerns lines that consist of only white space and comments; comments after actual contents are not concerned.

as.one

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.

clean.spaces

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

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.

match.exactly

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".

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.

keepEmpty

Deprecated. See keep.empty.

keepName

Deprecated. See keep.name.

keepComments

Deprecated. See keep.comments.

asOne

Deprecated. See as.one.

cleanSpaces

Deprecated. See clean.spaces.

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(), NMgenText(), NMreadSection(), NMreplaceDataFile(), NMwriteSection()

Examples

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

NMdata documentation built on Nov. 11, 2023, 5:07 p.m.