Datasets configuration can be provided in a yaml file or as a nested list. Below you can find a detailed description of possible options.

Data frames in a dataset

A single YAML file can include multiple data frames. Entry for each will be used as name of the data frame when it comes to generating data.

first_data_frame:
  ...
second_data_frame:
  ...
third_data_frame:
  ...

Data frame configuration

Data frame configuration includes two sections:

  1. columns - where you can describe columns of your data frame.
  2. default_size - optional value that describes default size of the data frame.

Columns

Each column of your data frame should be described in a separate entry in columns section. Entry name will be used as column name.

Currently there are three major types of columns implemented:

  1. Built-in basic columns (integer, numeric, string, boolean and set)
  2. Columns that use custom function to be generated.
  3. Columns calculated from other columns.

Type of column is set by choosing a proper type value in column description. Check following sections for more details.

The order of columns will be the same as the order of entries in the configuration.

Built-in columns

Basic column types. For an example YAML configuration check this

integer

Random integers from a range

Parameters:

Example:

data_frame:
  columns:
    integer_column:
      type: integer
      min: 2
      max: 10
numeric

Random float numbers from a range

Parameters:

Example:

data_frame:
  columns:
    numeric_column:
      type: numeric
      min: 2.12
      max: 10.3
string

Random string that follows given pattern

Parameters:

Example:

data_frame:
  columns:
    string_column:
      type: string
      length: 3
      pattern: "[ACGT]"
boolean

Random boolean

Parameters:

Example:

data_frame:
  columns:
    boolean_column:
      type: boolean
set

Column with elements from a set

Parameters:

Example:

data_frame:
  columns:
    set_column_one:
      type: set
      set: ["aardvark", "elephant", "hedgehog"]
    set_column_two:
      type: set
      set_type: integer
      set_size: 3
      min: 2
      max: 10
date

Column with dates

Parameters:

Example:

data_frame:
  columns:
    date_column:
      type: date
      min_date: 2012-03-31
      max_date: 2015-12-23
time

Column with times

Parameters:

Example:

data_frame:
  columns:
    time_column:
      type: time
      min_time: "12:23:00"
      max_time: "15:48:32"
      resolution: "seconds"
datetime

Column with datetimes

Parameters:

Example:

data_frame:
  columns:
    time_column:
      type: datetime
      min_date: 2012-03-31
      max_date: 2015-12-23
      min_time: "12:23:00"
      max_time: "15:48:32"
      time_resolution: "seconds"

Special columns

Special predefined types of columns. For an example YAML configuration check this

id

Id column - ordered integer that starts from defined value (default: 1).

Parameters:

Example:

data_frame:
  columns:
    id_column:
      type: id
      start: 2
distribution

Column filled with values that follow given statistical distribution. You can use one of the distributions available here. You can use function name (e.g. rnorm) or regular distribution name (e.g. "Normal"). For available names, check this file.

Parameters:

Example:

data_frame:
  columns:
    normal_distribution:
      type: distribution
      distribution_type: Gaussian
    bernoulli_distribution:
      type: distribution
      distribution_type: binomial
      size: 1
      prob: 0.5
    poisson_distribution:
      type: distribution
      distribution_type: Poisson
      lambda: 3
    beta_distribution:
      type: distribution
      distribution_type: rbeta
      shape1: 20
      shape2: 30
    cauchy_distribution:
      type: distribution
      distribution_type: Cauchy-Lorentz

Custom columns

There are two levels of custom generator that can be used. You can provide a function that generates a single value or a function that provides a whole column. For examples check this configuration and this R script with functions.

custom value generator

Generate column values using custom function available in your environment. Function should return a single value.

Parameters:

Example:

return_sample_paste <- function(vector_of_values) {
  values <- sample(vector_of_values, 2)
  paste(values, collapse = "_")
}
data_frame:
  columns:
    custom_column:
      type: custom
      custom_generator: return_sample_paste
      vector_of_values: ["a", "b", "c", "d"]
custom column generator

Generate column using custom function available in your environment. Function should accept argument size and return a vector of length equal to it.

Parameters:

Example:

return_repeated_value <- function(size, value) {
  rep(value, times = size)
}
data_frame:
  columns:
    custom_column:
      type: custom_column
      custom_column_generator: return_repeated_value
      value: "Ask me about trilobites!"

Calculated columns

Calculate columns that depend on other columns. For examples check this configuration and this R script with functions.

Parameters:

In general, formula can be a simple expression or a call of more complex function. In both cases formula has to include names of the columns required for the calculations. When using a function, make sure that it returns a vector of the same size as inputs.

Example:

check_column <- function(column) {
  purrr::map_lgl(column, ~.x >= 10)
}
data_frame:
  columns:
    basic_column:
      type: integer
      min: 1
      max: 10
    second_basic_column:
      type: integer
      min: 1
      max: 10
    calculated_column:
      type: calculated
      formula: basic_column + second_basic_column
    second_calculated_column:
      type: calculated
      formula: check_column(calculated_column)

Default size

Data frame can have a default number of rows that will be returned if size argument is not provided. Default size can be one of:

Example:

data_frame:
  columns:
    ...
  default_size: 10

Example:

random_number_of_rows:
  columns:
    ...
  default_size:
    arguments:
      min: 10
      max: 20
static_random_number_of_rows:
  columns:
    ...
  default_size:
    arguments:
      min: 5
      max: 10
    static: TRUE

For sample YAML configuration check this.

Arrange data frame

Data frame can be arranged by columns by providing a list of column names as arange field.

Example:

data_frame:
  columns:
    a:
      ...
    b:
      ...
    c:
      ...
    d:
      ...
  arrange: [a, c]


jakubnowicki/fixtuRes documentation built on Feb. 20, 2022, 6:14 a.m.