OHDSI / FeatureExtraction

An R package for generating features (covariates) for a cohort using data in the Common Data Model.
http://ohdsi.github.io/FeatureExtraction/
61 stars 60 forks source link

Handling Arguments for Custom Covariates #151

Closed cukarthik closed 2 years ago

cukarthik commented 2 years ago

I have a custom covariate that I'm working on that depends on a table that is loaded in the results schema, but my query fails when it tries to access resultsDatabaseSchema even though I specify it as a parameter to my getDbLooCovariateData function.

Based on this line of code, there is a fixed set of parameters that will be passed to my custom covariate. If this is the issue preventing adding additional parameters, I can try to create a PR.

@schuemie @anthonysena

cukarthik commented 2 years ago

Just checking if this is an issue and if so, then I'll work on a fix if it helps. Right now, I source my R script in order to get my package to take the variable I want to pass; this seems to work but is probably not the right solution.

anthonysena commented 2 years ago

Hi @cukarthik - my suggestion would be to include the table name as part of the covariate settings. The vignette here provides an example of this:

createLooCovariateSettings <- function(useLengthOfObs = TRUE) {
  covariateSettings <- list(useLengthOfObs = useLengthOfObs)
  attr(covariateSettings, "fun") <- "getDbLooCovariateData"
  class(covariateSettings) <- "covariateSettings"
  return(covariateSettings)
}

So you could change this to something like covariateSettings <- list(myTableForUseInCovariateBuilding= <value>) and then use that from the custom function attr(covariateSettings, "fun") <- "getDbLooCovariateData".

cukarthik commented 2 years ago

Thanks @anthonysena, I believe I did this and had the error, but maybe I did something different. I'll try it again and let you know. Thanks.

cukarthik commented 2 years ago

Thanks again, @anthonysena . I think that worked. I think my initial issue might have been my environment. Thanks again!