Learn R Programming

wyz.code.metaTesting (version 1.1.4)

DataFactory: Data Factory

Description

Class DataFactory from package wyz.code.metaTesting.

Usage

DataFactory()

Arguments

Value

An object of class DataFactory, that is an environment.

Details

It allows to generate data easily, either using generic data generation function named drawValues or using specific type generation function as drawRaw for example. All the data generation function names start with draw.

It is an extensible data factory. You may register your own data types and be able to use it as easily as using provided data generation functions. Use

See examples below.

Examples

Run this code
# NOT RUN {
# typical use case
df <- DataFactory()

# discover data generation function names
ls(df, pattern = 'draw*')

# discover recorded types
print(df$getRecordedTypes())

# discover known suffixes
print(df$retrieveKnownSuffixes())

# draw integer values using generic data generation function
# note that a semantic identifier is required, not just a known suffix extension
df$drawValues('x_i', 3)

df$drawValues('x_i_7', 16) # will draw 7 values. Semantic identifier contract wins.

# draw 8 values from aleatory chosen type
df$drawValues(paste0('x_', sample(df$retrieveKnownSuffixes(), 1)), 8)

# draw specified type (raw) using specifc data generation function
v <- df$drawRaw(10)
typeof(v) # raw
# }

Run the code above in your browser using DataLab