extract_pattern: Extract patterns from larger documents

Description Usage Arguments Value See Also Examples

View source: R/extract_pattern.R

Description

This function loads a file and scans it for a given keyword which signposts the beginning and end of a pattern. It then extracts all the text between the keywords for manipulation as a pattern. For extracting multiple patterns at once from a single file, check out extract_draft.

Usage

1
extract_pattern(filepath, keyword, preserve = FALSE)

Arguments

filepath

A valid character string to the plaintext file containing the pattern.

keyword

A placeholder which signposts the beginning and end of the pattern to be extracted.

preserve

A boolean (TRUE/FALSE) value indicating whether or not keywords should be included in the extracted pattern (TRUE) or not (FALSE); default FALSE.

Value

A character string, typically used to assemble a draft.

See Also

Other import functions: extract_draft(), import_draft(), import_pattern()

Examples

1
2
3
pattern_file <- tempfile("out", tempdir(), ".Rmd")
export_template("EXTRACT my sample pattern EXTRACT", pattern_file)
extract_pattern(pattern_file, "EXTRACT")

Example output

[1] " my sample pattern "

heddlr documentation built on March 24, 2020, 9:07 a.m.