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.
createRWrapperForSql(
sqlFilename,
rFilename,
packageName,
createRoxygenTemplate = TRUE
)
The SQL file.
The name of the R file to be generated. Defaults to the name of the SQL file with the extension reset to R.
The name of the package that will contains the SQL file.
If true, a template of Roxygen comments will be added.
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.
if (FALSE) {
# This will create a file called CohortMethod.R:
createRWrapperForSql("CohortMethod.sql", packageName = "CohortMethod")
}