createRWrapperForSql: Create an R wrapper for SQL

View source: R/HelperFunctions.R

createRWrapperForSqlR Documentation

Create an R wrapper for SQL

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

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 extension 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

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

## End(Not run)

OHDSI/SqlRender documentation built on March 26, 2024, 5:32 p.m.