View source: R/ImportFromCsv.R
insertCsvToDatabase | R Documentation |
This function converts a folder with csv results into plp objects and loads them into a plp result database
insertCsvToDatabase(
csvFolder,
connectionDetails,
databaseSchemaSettings,
modelSaveLocation,
csvTableAppend = ""
)
csvFolder |
The location to the csv folder with the plp results |
connectionDetails |
A connection details for the plp results database that the csv results will be inserted into |
databaseSchemaSettings |
A object created by |
modelSaveLocation |
The location to save any models from the csv folder - this should be the same location you picked when inserting other models into the database |
csvTableAppend |
A string that appends the csv file names |
The user needs to have plp csv results in a single folder and an existing plp result database
Returns a data.frame indicating whether the results were inported into the database
# develop a simple model on simulated data
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n=1000)
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"))
# now insert the csv results into a database
newDatabasePath <- file.path(tempdir(), "newDatabase.sqlite")
connectionDetails <-
DatabaseConnector::createConnectionDetails(dbms = "sqlite",
server = newDatabasePath)
insertCsvToDatabase(csvFolder = file.path(saveLoc, "csv"),
connectionDetails = connectionDetails,
databaseSchemaSettings = createDatabaseSchemaSettings(),
modelSaveLocation = file.path(saveLoc, "models"))
# clean up
unlink(saveLoc, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.