OHDSI Home | Forums | Wiki | Github

Error seen running script to upload dbProfile results to local schema

I’m running the “Upload dbProfile results to a local schema” R script described at How to Run and Upload dbProfile Results • DbDiagnostics and getting the error shown below.

I’m guessing that this is because the data file has column names like “stratum1”, “stratum2”, “stratum3”, etc. and the script seems to be looking for “STRATUM_1”

My output file and the R script are attached.
03-db-profile-upload.R.txt (2.7 KB)
db_profile_results.csv.txt (277.7 KB)

Error:

 # set the location of the results that were generated from executeDbProfile
> resultsLocation <- "D:\\_YES_2023-05-28\\workspace\\SosExamples\\_COVID\\02-data-diagnostics\\output\\NACHC_DEMO_DB_OHDSI\\20190525"
> 
> # set a parameter detailing if the DQD was run
> addDQD <- FALSE
> 
> # add dbId and prep output files for writing into the results schema
> db_profile_results <- read.csv(paste0(resultsLocation,"/db_profile_results.csv"), stringsAsFactors = F, colClasses = c("STRATUM_1"="character"))
Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote,  :
  not all columns named in 'colClasses' exist
> 
> # make sure the columns are read in as characters to facilitate dbDiagnostics execution
> db_profile_results$STRATUM_1 <- as.character(db_profile_results$STRATUM_1)
Error in `$<-.data.frame`(`*tmp*`, STRATUM_1, value = character(0)) : 
  replacement has 0 rows, data has 3077
>

Changing the instances of STRATUM_X to stratumX seems to have fixed this. I also made some adjustments to how the file parameters are defined. The script that worked for me is attached.

03-db-profile-upload_FIXED.R.txt (3.2 KB)

t