Running examples in ‘healthcareai-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: LassoDeployment
> ### Title: Deploy a production-ready predictive Lasso model
> ### Aliases: LassoDeployment
> ### Keywords: datasets
> 
> ### ** Examples
> 
> 
> 
> #### Classification Example using csv data ####
> ## 1. Loading data and packages.
> ptm <- proc.time()
> library(healthcareai)
> # setwd('C:/Yourscriptlocation/Useforwardslashes') # Uncomment if using csv
> 
> # Can delete this line in your work
> csvfile <- system.file("extdata", 
+                        "HCRDiabetesClinical.csv", 
+                        package = "healthcareai")
> 
> # Replace csvfile with 'path/file'
> df <- read.csv(file = csvfile, 
+                header = TRUE, 
+                na.strings = c("NULL", "NA", ""))
> 
> df$PatientID <- NULL # Only one ID column (ie, PatientEncounterID) is needed remove this column
> 
> # Save a dataframe for validation later on
> dfDeploy <- df[951:1000,]
> 
> ## 2. Train and save the model using DEVELOP
> print('Historical, development data:')
[1] "Historical, development data:"
> str(df)
'data.frame':	1000 obs. of  6 variables:
 $ PatientEncounterID : int  1 2 3 4 5 6 7 8 9 10 ...
 $ SystolicBPNBR      : int  167 153 170 187 188 185 189 149 155 160 ...
 $ LDLNBR             : int  195 214 191 135 125 178 101 160 144 130 ...
 $ A1CNBR             : num  4.2 5 4 4.4 4.3 5 4 5 6.6 8 ...
 $ GenderFLG          : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
 $ ThirtyDayReadmitFLG: Factor w/ 2 levels "N","Y": 1 1 1 1 1 1 1 1 1 2 ...
> 
> set.seed(42)
> p <- SupervisedModelDevelopmentParams$new()
> p$df <- df
> p$type <- "classification"
> p$impute <- TRUE
> p$grainCol <- "PatientEncounterID"
> p$predictedCol <- "ThirtyDayReadmitFLG"
> p$debug <- FALSE
> p$cores <- 1
> 
> # Run Lasso
> Lasso<- LassoDevelopment$new(p)
> Lasso$run()
Area under the ROC curve is: 0.77 
Ideal cutoff is 0.17, yielding TPR of 0.83 and FPR of 0.32 
95% CI AU_ROC: (0.67 , 0.88) 

Area under the PR curve is: 0.30 
Ideal cutoff is 0.18, yielding Precision of 0.43 and Recall of 0.60 

Grouped Lasso coefficients: 
  (Intercept) SystolicBPNBR        LDLNBR        A1CNBR    GenderFLGM 
   -3.0095923     0.0000000     0.0000000     0.2102113     0.0000000 
Variables with non-zero coefficients:  A1CNBR 
> 
> ## 3. Load saved model and use DEPLOY to generate predictions. 
> print('Fake production data:')
[1] "Fake production data:"
> str(dfDeploy)
'data.frame':	50 obs. of  6 variables:
 $ PatientEncounterID : int  951 952 953 954 955 956 957 958 959 960 ...
 $ SystolicBPNBR      : int  125 112 111 166 161 165 176 163 167 161 ...
 $ LDLNBR             : int  122 144 145 119 106 118 145 112 123 106 ...
 $ A1CNBR             : num  6.4 6 6 8 8 8 8 8 8 8 ...
 $ GenderFLG          : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
 $ ThirtyDayReadmitFLG: Factor w/ 2 levels "N","Y": 1 1 1 2 2 2 2 2 2 2 ...
> 
> p2 <- SupervisedModelDeploymentParams$new()
> p2$type <- "classification"
> p2$df <- dfDeploy
> p2$grainCol <- "PatientEncounterID"
> p2$predictedCol <- "ThirtyDayReadmitFLG"
> p2$impute <- TRUE
> p2$debug <- FALSE
> p2$cores <- 1
> 
> dL <- LassoDeployment$new(p2)
Loading Model Info... 
The modelName parameter was not specified. Using defaults:
- rmodel_probability_lasso.rda
- rmodel_info_lasso.rda
Loading Data... 
> dL$deploy()
Model metadata written to predictionMetadata_default_2018-03-25_18.54.11.133.txt
WARNING: **This file may contain PHI.**
> 
> dfOut <- dL$getOutDf()
> head(dfOut)
  BindingID BindingNM         LastLoadDTS PatientEncounterID PredictedProbNBR
1         0         R 2018-03-25 18:54:10                951        0.1591936
2         0         R 2018-03-25 18:54:10                952        0.1482586
3         0         R 2018-03-25 18:54:10                953        0.1482586
4         0         R 2018-03-25 18:54:10                954        0.2095066
5         0         R 2018-03-25 18:54:10                955        0.2095066
6         0         R 2018-03-25 18:54:10                956        0.2095066
  Factor1TXT    Factor2TXT  Factor3TXT
1     A1CNBR SystolicBPNBR GenderFLG.M
2     A1CNBR SystolicBPNBR GenderFLG.M
3     A1CNBR SystolicBPNBR GenderFLG.M
4     A1CNBR SystolicBPNBR GenderFLG.M
5     A1CNBR SystolicBPNBR GenderFLG.M
6     A1CNBR SystolicBPNBR GenderFLG.M
> # Write to CSV (or JSON, MySQL, etc) using plain R syntax
> # write.csv(dfOut,'path/predictionsfile.csv')
> 
> print(proc.time() - ptm)
   user  system elapsed 
  0.794   0.047   1.022 
> 
> 
> 
> #### Classification example pulling from CSV and writing to SQLite ####
> 
> ## 1. Loading data and packages.
> ptm <- proc.time()
> library(healthcareai)
> 
> # Can delete these system.file lines in your work
> csvfile <- system.file("extdata", 
+                        "HCRDiabetesClinical.csv", 
+                        package = "healthcareai")
>                        
> sqliteFile <- system.file("extdata",
+                           "unit-test.sqlite",
+                           package = "healthcareai")
> 
> # Read in CSV; replace csvfile with 'path/file'
> df <- read.csv(file = csvfile, 
+                header = TRUE, 
+                na.strings = c("NULL", "NA", ""))
> 
> df$PatientID <- NULL # Only one ID column (ie, PatientEncounterID) is needed
> 
> # Save a dataframe for validation later on
> dfDeploy <- df[951:1000,]
> 
> ## 2. Train and save the model using DEVELOP
> print('Historical, development data:')
[1] "Historical, development data:"
> str(df)
'data.frame':	1000 obs. of  6 variables:
 $ PatientEncounterID : int  1 2 3 4 5 6 7 8 9 10 ...
 $ SystolicBPNBR      : int  167 153 170 187 188 185 189 149 155 160 ...
 $ LDLNBR             : int  195 214 191 135 125 178 101 160 144 130 ...
 $ A1CNBR             : num  4.2 5 4 4.4 4.3 5 4 5 6.6 8 ...
 $ GenderFLG          : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
 $ ThirtyDayReadmitFLG: Factor w/ 2 levels "N","Y": 1 1 1 1 1 1 1 1 1 2 ...
> 
> set.seed(42)
> p <- SupervisedModelDevelopmentParams$new()
> p$df <- df
> p$type <- "classification"
> p$impute <- TRUE
> p$grainCol <- "PatientEncounterID"
> p$predictedCol <- "ThirtyDayReadmitFLG"
> p$debug <- FALSE
> p$cores <- 1
> 
> # Run lasso
> Lasso <- LassoDevelopment$new(p)
> Lasso$run()
Area under the ROC curve is: 0.77 
Ideal cutoff is 0.17, yielding TPR of 0.83 and FPR of 0.32 
95% CI AU_ROC: (0.67 , 0.88) 

Area under the PR curve is: 0.30 
Ideal cutoff is 0.18, yielding Precision of 0.43 and Recall of 0.60 

Grouped Lasso coefficients: 
  (Intercept) SystolicBPNBR        LDLNBR        A1CNBR    GenderFLGM 
   -3.0095923     0.0000000     0.0000000     0.2102113     0.0000000 
Variables with non-zero coefficients:  A1CNBR 
> 
> ## 3. Load saved model and use DEPLOY to generate predictions. 
> print('Fake production data:')
[1] "Fake production data:"
> str(dfDeploy)
'data.frame':	50 obs. of  6 variables:
 $ PatientEncounterID : int  951 952 953 954 955 956 957 958 959 960 ...
 $ SystolicBPNBR      : int  125 112 111 166 161 165 176 163 167 161 ...
 $ LDLNBR             : int  122 144 145 119 106 118 145 112 123 106 ...
 $ A1CNBR             : num  6.4 6 6 8 8 8 8 8 8 8 ...
 $ GenderFLG          : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
 $ ThirtyDayReadmitFLG: Factor w/ 2 levels "N","Y": 1 1 1 2 2 2 2 2 2 2 ...
> 
> p2 <- SupervisedModelDeploymentParams$new()
> p2$type <- "classification"
> p2$df <- dfDeploy
> p2$grainCol <- "PatientEncounterID"
> p2$predictedCol <- "ThirtyDayReadmitFLG"
> p2$impute <- TRUE
> p2$debug <- FALSE
> p2$cores <- 1
> 
> dL <- LassoDeployment$new(p2)
Loading Model Info... 
The modelName parameter was not specified. Using defaults:
- rmodel_probability_lasso.rda
- rmodel_info_lasso.rda
Loading Data... 
> dL$deploy()
Model metadata written to predictionMetadata_default_2018-03-25_18.54.12.132.txt
WARNING: **This file may contain PHI.**
> dfOut <- dL$getOutDf()
> 
> writeData(SQLiteFileName = sqliteFile,
+           df = dfOut,
+           tableName = 'HCRDeployClassificationBASE')
Error in rsqlite_bind_rows(rs@ptr, value) : 
  attempt to write a readonly database
Calls: writeData ... .local -> tryCatch -> tryCatchList -> rsqlite_bind_rows
Execution halted