createRWrapperForSql: Create an R wrapper for SQL

Description Usage Arguments Details Examples

View source: R/HelperFunctions.R

Description

createRWrapperForSql creates an R wrapper for a parameterized SQL file. The created R script file will contain a single function, that executes the SQL, and accepts the same parameters as specified in the SQL.

Usage

1
2
createRWrapperForSql(sqlFilename, rFilename, packageName,
  createRoxygenTemplate = TRUE)

Arguments

sqlFilename

The SQL file.

rFilename

The name of the R file to be generated. Defaults to the name of the SQL file with the extention reset to R.

packageName

The name of the package that will contains the SQL file.

createRoxygenTemplate

If true, a template of Roxygen comments will be added.

Details

This function reads the declarations of defaults in the parameterized SQL file, and creates an R function that exposes the parameters. It uses the loadRenderTranslateSql function, and assumes the SQL will be used inside a package. To use inside a package, the SQL file should be placed in the inst/sql/sql_server folder of the package.

Examples

1
2
3
4
5
## Not run: 
# This will create a file called CohortMethod.R:
createRWrapperForSql("CohortMethod.sql", packageName = "CohortMethod")

## End(Not run)

SqlRender documentation built on Feb. 15, 2019, 5:06 p.m.