Skip to contents

This function will find all specifications in the Access registration database via SQL code. For example where the orginal data is and how the data will be restructured and aggregated.. etc.. etc.. The specifications are registered in the following tables:

  1. tbl_Filgruppe - File group specification for the output

  2. tbl_Orgfile - The original files

  3. tbl_Innlesing - How the file will be read into R

  4. tbl_Koble - Connection for original files to the file groups and how these will be read

  5. tbl_KodeBok - Code book to recode any value

  6. tbl_Compute - Code book to create a new category from the existing categories

SQL file must be written with base::sprintf style ie. '%s','%d' etc. Please refer to base::sprintf documentation. In addition, SQL code must not contain comments. Example of SQL code with '%s': SELECT * FROM tbl_Koble WHERE FILGRUPPE = '%s' Which is saved in C:/myfile.sql and run as in the code example.

Usage

find_spec(
  file = NULL,
  value = NULL,
  con = NULL,
  external = FALSE,
  char = NULL,
  char2 = NULL,
  char3 = NULL,
  opposite = FALSE,
  asis = FALSE
)

Arguments

file

SQL file. If external is TRUE then complete filepath must be specified.

value

The value for selection in SQL code with base::sprintf style. For example the name of a filgruppe.

con

Connection to database

external

If the SQL file is outside of the package. Default is FALSE.

char

First input value to be added in the query

char2

Second input value to be added in the query

char3

Third input value to be added in the query

opposite

TRUE if second input value will be read before first input value

asis

TRUE if sql code file should be read as it is without any other input

Value

Out put will be a data.frame.

Examples

if (FALSE) { # \dontrun{
qr <- find_spec("C:/myfile.sql", value = "BEFOLKNING", con = dbconn, external = TRUE)
qr2 <- find_spec("your.sql", con = dbconn, char = "BEFOLKNING", char2 = 14)
} # }