Skip to contents

Retrieves a text file from the improve repository and loads it as a character string with metadata including caption and description. All lines are collapsed into a single string with newline separators.

Usage

getTextString(
  ident,
  from = pwd(),
  addAsLink = TRUE,
  caption = "",
  description = "",
  ...
)

Arguments

ident

Path, resource ID, or entity ID of the text file. Can be a relative path (from current step), absolute path, or improve identifier

from

Root path for resolving relative paths. Defaults to pwd() (current step location)

Logical. If TRUE, creates a link in the inventory for provenance tracking. Use improveClean() at workflow end to clean up links

caption

Custom caption text. If empty, defaults to entityID and lastModified timestamp

description

Custom description text. If empty, defaults to filename

...

Additional arguments passed to readLines()

Value

A list object (descriptor) with the following components:

  • data: Character string containing the complete file contents with lines collapsed using newline (\n) separators

  • dataType: Character string set to "Text"

  • path: Character string with local file path

  • caption: Character string with caption text

  • description: Character string with description text

  • Additional metadata fields from the resource descriptor

Details

The function reads all lines from the text file using readLines() and collapses them into a single character string. The returned descriptor integrates with improve's provenance tracking when addAsLink = TRUE. Access the text content via result$data.

References

ics1141

See also

getData for loading data tables, getR for loading R objects, getHTML for loading HTML files

Examples

if (FALSE) { # \dontrun{
# Load text file from current step
text_desc <- getTextString("report_text.txt")
content <- text_desc$data  # Extract text string

# Load file with custom metadata
script_desc <- getTextString(
  "scripts/analysis.R",
  caption = "Main Analysis Script",
  description = "Primary statistical analysis code"
)
} # }