expandTable: expandTable: Expands database rows into multiple database...

Description Usage Arguments Details Value Author(s) Examples

View source: R/sqliteTools.r

Description

Reads readTable and writes replicated and equally distributed values into writeTable.

Usage

1
expandTable(dbfile, tables, boundCols, indexCol, copyCols, expandCols, verbose=FALSE)

Arguments

dbfile

character. Name of database file.

tables

character. Name of read table and write table.

boundCols

character. Name of boundary columns: loBound and hiBound

indexCol

character. Name of index column which is written to output table.

copyCols

character. Name of columns which are copied.

expandCols

character. Name of columns which are expanded.

verbose

numeric. Verbosity of printed output.

Details

The function expands 'indexCol' value for values between first and second boundCols value.

Value

Integer. Number of rows inserted into output table.

Author(s)

Wolfgang Kaisers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
n <- 5
v <- 1:n
dfr <- data.frame(id=v,
                exp1 = v * 100/7,
                exp2 = v * 200/7,
                cpy1 = letters[v],
                cpy2 = 2*v,
                min_woche = v*100 - 1,
                max_woche = v*100 + 1)

dbfile <- file.path(".", "test.db3")
tables <- c("tbl", "rtbl")
boundCols <- c("min_woche", "max_woche")
indexCol <- "woche"
copyCols <- c("cpy1", "cpy2")
expandCols <- c("exp1", "exp2")
verbose <- 1L


# Write SQLite database. Contains test data
con <- dbConnect(RSQLite::SQLite(), dbfile)
dbWriteTable(con, tables[1], dfr, overwrite=TRUE)
dbDisconnect(con)
# Do replicate
nr <- expandTable(dbfile, tables, boundCols, indexCol, copyCols, expandCols, verbose)
nr

sqliteTools documentation built on May 2, 2019, 5:46 p.m.