fromto {fritools2}R Documentation

Extract All Items of a Vector Between Two Patterns

Description

This comes in handy to cut lines from a file read by readLines.

Usage

fromto(
  x,
  from,
  to,
  from_i = 1,
  to_i = 1,
  shift_from = 0,
  shift_to = 0,
  remove_empty_item = TRUE
)

Arguments

x

A vector.

from

A pattern, use NA to start with the first item.

to

Another pattern, use NA to stop with the last item.

from_i

If the from pattern matches multiple times, which one is to be used.

to_i

Analogously to to_i.

shift_from

The number of items to shift from the item selected via from and from_i.

shift_to

Analogously to shift_from.

remove_empty_item

Remove empty items?

Value

The extracted vector.

See Also

Other searching functions: compare_vectors(), file_modified_last(), find_files(), grep_file(), missing_docs, search_files(), search_rows(), summary.filesearch()

Examples

foo <- c("First", "f1", "A", "f2", rep("B", 4), "t1", "f3", "C", "t2",
         rep("D", 4), "t3", "Last")
fromto(foo, "^f", "^t")
fromto(foo, NA, "^t")
fromto(foo, "^f", NA)
fromto(foo, "^f", "^t", from_i = 2)
fromto(foo, "^f", "^t", from_i = 2, to_i = 2)
fromto(foo, "^f", "^t", from_i = 2, to_i = 2, shift_from = 1, shift_to = -1)
fromto(foo, "^f", "^t", from_i = 2, to_i = 2, shift_from = -1, shift_to = 2)

[Package fritools2 version 4.1.0 Index]