Attempts to classify a data frame as one of the common ADaM dataset classes
from its variables and records. It ignores any class declared with
admiral_df(): get_dataset_class() returns the declared class if there is
one, and only falls back to this function otherwise.
Note that this is the class of the dataset (ADSL, BDS, ...), not its
record structure: the latter is the set of key variables which uniquely
identify its records. Unlike the class, the keys are never inferred; they are
only ever declared with admiral_df().
Value
A character scalar: one of "ADSL", "BDS", "OCCDS", "TTE",
"ADDL", "MDBDS", "MDTTE", "MDOCCDS", or "other"; or NA if the
dataset has no records and its variables do not decide the class.
Details
A dataset is first classed as device data or subject data:
Device data contains
SPDEVID, the device identifier, populated (neitherNAnor"") for every record. Its class is one of the medical device classes"ADDL","MDBDS","MDTTE", and"MDOCCDS".Subject data is otherwise data which contains all the subject keys (
get_admiral_option("subject_keys"), by defaultSTUDYIDandUSUBJID). Its class is one of"ADSL","BDS","OCCDS", and"TTE".
A dataset which is neither is "other". This keeps a data frame which merely
shares variable names with an ADaM dataset – a coding dictionary with
AETERM/AEDECOD columns, a summary table with PARAMCD and AVAL –
from being taken for one.
The subject keys do not decide the class: in the ADaMIG-MD STUDYID is
required in a device dataset and USUBJID is conditional, so a device
dataset may identify the subject of every record. Nor does the presence of
SPDEVID, as subject datasets record it too, e.g. the device involved in
an adverse event; but there it is populated only for the records which
involve a device. A subject dataset in which every record involves a device
(e.g. an ADAE restricted to device-related events) is therefore inferred
as device data, so declare its class with admiral_df() instead.
Within each class the following precedence is used. The order matters,
because the classes are not mutually exclusive by variable content – a TTE
dataset contains PARAMCD just as a BDS one does, and an occurrence
dataset which has had a parameter added is structurally both.
"TTE"/"MDTTE"– containsPARAMCD,CNSR, andSTARTDT. Tested first because a time-to-event dataset is aBDSdataset by variable content; only the censoring and origin-date variables distinguish it."BDS"/"MDBDS"– containsPARAMCDandAVALorAVALC."OCCDS"/"MDOCCDS"– does not containPARAMCD, and contains a--DECOD/--TERMvariable with a two-letter SDTM domain prefix (AEDECOD,DETERM, ...; a variable merely ending inTERMdoes not count), anAOCCxxFLoccurrence flag, orTRTEMFL."ADSL"/"ADDL"– does not containPARAMCDand has one record per subject (per combination of the subject keys) or per device (per combination ofSTUDYIDandSPDEVID). This is decided by the records: treatment variables are no evidence of ADSL, asBDS/OCCDSderivations merge them on from ADSL."other"– none of the above, if there is at least one record.NA– none of the above.
