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

getDbCovariateData returns CovariateData class #93

Closed gowthamrao closed 4 years ago

gowthamrao commented 4 years ago

https://github.com/OHDSI/FeatureExtraction/blob/cd516ed0a938143d434871f2df677bc47e83982d/R/GetCovariates.R#L64

> data
# CovariateData object

Cohort of interest ID: 323432

Inherits from Andromeda:
# Andromeda object
# Physical location:  C:\Users\ADMIN_~2\AppData\Local\Temp\2\RSNV\file1529.sqlite

Tables:
$analysisRef (analysisId, analysisName, domainId, startDay, endDay, isBinary, missingMeansZero)
$covariateRef (covariateId, covariateName, analysisId, conceptId)
$covariates (covariateId, sumValue, averageValue)
$covariatesContinuous (covariateId, countValue, minValue, maxValue, averageValue, standardDeviation, medianValue, p10Value, p25Value, p75Value, p90Value)

but...

!is.null(data$covariates) returns

Error in UseMethod("tbl") : 
  no applicable method for 'tbl' applied to an object of class "CovariateData"

Reason: the returned object data is

> isS4(data)
[1] TRUE
> class(data)
[1] "CovariateData"
is(data)
[1] "CovariateData"    "Andromeda"        "SQLiteConnection" "DBIConnection"    "DBIObject" 
> is(data, 'Andromeda')
[1] TRUE
> slotNames(data)
[1] "ptr"                 "dbname"              "loadable.extensions" "flags"               "vfs"                 "ref"                
[7] "bigint"

is of class CovariateData because of https://github.com/OHDSI/FeatureExtraction/blob/cd516ed0a938143d434871f2df677bc47e83982d/R/GetCovariates.R#L108

How to read the object data of class CovariateData like data$covariates?

Trying to solve this issue: https://github.com/OHDSI/CohortDiagnostics/issues/48

schuemie commented 4 years ago

I'm not able to reproduce this. Did you call library(FeatureExtraction) for running this code?

gowthamrao commented 4 years ago

Looks like R needed a restart. Closing this issue.