Learn R Programming

cdata (version 1.0.7)

build_pivot_control_q: Build a blocks_to_rowrecs_q() control table that specifies a pivot (query based, takes name of table).

Description

Some discussion and examples can be found here: https://winvector.github.io/FluidData/FluidData.html.

Usage

build_pivot_control_q(tableName, columnToTakeKeysFrom,
  columnToTakeValuesFrom, my_db, ..., prefix = columnToTakeKeysFrom,
  sep = NULL)

Arguments

tableName

Name of table to scan for new column names.

columnToTakeKeysFrom

character name of column build new column names from.

columnToTakeValuesFrom

character name of column to get values from.

my_db

db handle

...

not used, force later args to be by name

prefix

column name prefix (only used when sep is not NULL)

sep

separator to build complex column names.

Value

control table

See Also

blocks_to_rowrecs_q, build_pivot_control

Examples

Run this code
# NOT RUN {
if (requireNamespace("DBI", quietly = TRUE) &&
  requireNamespace("RSQLite", quietly = TRUE)) {
  my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
  d <- data.frame(measType = c("wt", "ht"),
                  measValue = c(150, 6),
                  stringsAsFactors = FALSE)
  rquery::rq_copy_to(my_db,
                    'd',
                    d,
                    overwrite = TRUE,
                    temporary = TRUE)
  build_pivot_control_q('d', 'measType', 'measValue',
                        my_db = my_db,
                        sep = '_') %.>%
     print(.)
  DBI::dbDisconnect(my_db)
}

# }

Run the code above in your browser using DataLab