find_gran: Find out granularity of a string vector

Description Usage Arguments Examples

Description

This helper function takes a string (vector) as an input and searches for the highest or lowest granularity. Granularity is defined in terms of a hash/ space sequence (see sum_str). The search is implemented using a recursive approach.

Usage

1
find_gran(direction = "down", highest = 3, lowest = 1, lines)

Arguments

direction

either "up" or "down". Down means the algorithm starts with the pattern containing a certain number of hashes (specified in highest) and searches for a regex match. If it can't find one, it reduces the number of hashes by one and searches again, until it finds a pattern.

highest

The highest level of granularity to search for.

lowest

The lowest level of granularity to search for.

lines

a character vector containing the lines to match against.

Examples

1
  strcode:::find_gran("down", highest = 3, lowest = 1, lines = c("##  .", "#   _"))

XiaoliangJiang/IndependentStudy2017YW documentation built on May 29, 2019, 10:54 a.m.