starschemar (version 1.2.0)

character_dimensions: Transform dimension numeric attributes to character

Description

Transforms numeric type attributes of dimensions into character type. In a star_schema numerical data are measurements that are situated in the facts. Numerical data in dimensions are usually codes, day, week, month or year numbers. There are tools that consider any numerical data to be a measurement, for this reason it is appropriate to transform the numerical data of dimensions into character data.

Usage

character_dimensions(st, length_integers = list(), NA_replacement_value = NULL)

# S3 method for star_schema character_dimensions(st, length_integers = list(), NA_replacement_value = NULL)

Arguments

st

A star_schema object.

length_integers

A list of pairs name = length, for each attribute name its length.

NA_replacement_value

A string, value to replace NA values.

Value

A star_schema object.

Details

It allows indicating the amplitude for some fields, filling with zeros on the left. This is useful to make the alphabetical order of the result correspond to the numerical order.

It also allows indicating the literal to be used in case the numerical value is not defined.

If a role playing dimension has been defined, the transformation is performed on it.

See Also

Other star schema and constellation definition functions: constellation(), role_playing_dimension(), snake_case(), star_schema()

Examples

Run this code
# NOT RUN {
library(tidyr)

st <- star_schema(mrs_age_test, dm_mrs_age) %>%
  role_playing_dimension(
    dim_names = c("when", "when_available"),
    name = "When Common",
    attributes = c("date", "week", "year")
  ) %>%
  character_dimensions(length_integers = list(week = 2),
                       NA_replacement_value = "Unknown")

# }

Run the code above in your browser using DataCamp Workspace