setRegEx: Set regex for the accepted values of the variable(s)

Description Usage Arguments Value Examples

Description

setRegEx assigns a regexp to the values of each variable specified in the input parameters.

Usage

1
2
3
4
setRegEx(schema, regex, variables)

## S4 method for signature 'StfwfSchema,character'
setRegEx(schema, regex, variables)

Arguments

schema

Object of class StfwfSchema.

regex

charactec vector with the new regex for the accepted values of the variables.

variables

character vector with the names of the variables whose regex are to be updated.

Value

Object of class StfwfSchema.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# A trivial example:
df <- data.frame(variable = c('Turnover', 'Employees'),
                 width = c(9L, 3L),
                 initialPos = c(1, 10),
                 finalPos = c(9, 12),
                 type = rep('num', 2),
                 valueRegEx = c('[0-9]{0,9}', '[0-9]{0,3}'),
                 description = c('Turnover of the business unit',
                                 'Number of employees of the business unit'),
                 stringsAsFactors = FALSE)
Schema <- new(Class = 'StfwfSchema', df = df)
setRegEx(Schema, c('[0-9]{0,10}'), 'Turnover')

david-salgado/fastReadfwf documentation built on Dec. 25, 2021, 12:43 p.m.