Learn R Programming

wyz.code.metaTesting (version 1.1.4)

retrieveDataFactory: Retrieve Data Factory

Description

As the data factory may be modified, this function allows you to make changes and to record them in your own specialized data generation factory, to match various needs and ease reuse.

Usage

retrieveDataFactory()

Arguments

Value

An R object that is a DataFactory.

Details

Retrieves a DataFactory from environment variable OP_DATA_FACTORY or provides a default type factory.

Examples

Run this code
# NOT RUN {
##---- typical case ----

draw_integer_array_dim2 <- function(n, replace_b_1 = TRUE) {
  m <- n + sample(0:3, 1)
  matrix(seq(1, n * m), byrow = TRUE, nrow = n,
         dimnames = list(paste('row_', 1:n), paste('col_', 1:m)))
}

df <- DataFactory()
df$addSuffix('a', "array", draw_integer_array_dim2)

Sys.setenv("OP_DATA_FACTORY" = "df")
fg <- retrieveDataFactory() # retrieves the factory pointed by R variable df
fg$getRecordedTypes()[suffix == 'a'] # right behavior !

# wrong behavior as retrieveDataFactory will provide the default factory and not yours!
Sys.setenv("OP_DATA_FACTORY" = "")
fh <- retrieveDataFactory() # retrieves the default factory
fh$getRecordedTypes()[suffix == 'a']
# }

Run the code above in your browser using DataLab