Learn R Programming

PatientLevelPrediction (version 6.4.1)

extractDatabaseToCsv: Exports all the results from a database into csv files

Description

Exports all the results from a database into csv files

Usage

extractDatabaseToCsv(
  conn = NULL,
  connectionDetails,
  databaseSchemaSettings = createDatabaseSchemaSettings(resultSchema = "main"),
  csvFolder,
  minCellCount = 5,
  sensitiveColumns = getPlpSensitiveColumns(),
  fileAppend = NULL
)

Value

The directory path where the results were saved

Arguments

conn

The connection to the database with the results

connectionDetails

The connectionDetails for the result database

databaseSchemaSettings

The result database schema settings

csvFolder

Location to save the csv files

minCellCount

The min value to show in cells that are sensitive (values less than this value will be replaced with -1)

sensitiveColumns

A named list (name of table columns belong to) with a list of columns to apply the minCellCount to.

fileAppend

If set to a string this will be appended to the start of the csv file names

Details

Extracts the results from a database into a set of csv files

Examples

Run this code
  # takes too long 
# develop a simple model on simulated data
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n = 500)
saveLoc <- file.path(tempdir(), "extractDatabaseToCsv")
results <- runPlp(plpData, outcomeId = 3, saveDirectory = saveLoc)
# now upload the results to a sqlite database
databasePath <- insertResultsToSqlite(saveLoc)
# now extract the results to csv
connectionDetails <- 
  DatabaseConnector::createConnectionDetails(dbms = "sqlite", 
                                             server = databasePath)
extractDatabaseToCsv(
  connectionDetails = connectionDetails,
  csvFolder = file.path(saveLoc, "csv")
)
# show csv file
list.files(file.path(saveLoc, "csv"))
# clean up
unlink(saveLoc, recursive = TRUE)

Run the code above in your browser using DataLab