toc_count_whitespace: Count white space at the start of the title

View source: R/set_eurostat_toc.R

toc_count_whitespaceR Documentation

Count white space at the start of the title

Description

Counts the number of white space characters at the start of the string.

Usage

toc_count_whitespace(input_string)

Arguments

input_string

A string containing Eurostat TOC titles

Details

Used in toc_determine_hierarchy function to determine hierarchy. Hierarchy is defined in Eurostat .txt format TOC files by the number of white space characters at intervals of four. For example, " Foo" (4 white space characters) is one level higher than " Bar" (8 white space characters). "Database by themes" (0 white space characters before the first alphanumeric character) is highest in the hierarchy.

The function will return a warning if the input has white space in anything else than as increments of 4. 0, 4, 8... are acceptable but 3, 6, 10... are not.

Value

Numeric (number of white space characters)

Author(s)

Pyry Kantanen

See Also

get_eurostat_toc() toc_count_children() toc_determine_hierarchy() toc_list_children() toc_count_whitespace()

Examples

strings <- c("    abc", "  cdf", "no_spaces")
for (string in strings) {
 whitespace_count <- eurostat:::toc_count_whitespace(string)
 cat("String:", string, "\tWhitespace Count:", whitespace_count, "\n")
}


rOpenGov/eurostat documentation built on Jan. 19, 2024, 11:45 a.m.