Skip to contents

Reads the row of cohort@subject_tbl whose subject_id equals id and returns it as a Subject object. A cohort stores its subjects as a table. Use this function when one subject is needed as an object.

Usage

subject(cohort, id)

Arguments

cohort

A Cohort object.

id

Character scalar with the subject_id to look up.

Value

A Subject built from the matching row.

Details

The Subject fields are read from the columns subject_id, species, sex, strain, genotype, cohort, timepoint, and notes. Values are coerced to character and missing values stay missing. A column that is absent from subject_tbl gives NA. Other columns are ignored.

An unknown id is an error. The error lists up to five ids that the cohort does have.

Examples

data(example_cohort)
rat1 <- subject(example_cohort, "RAT001")
rat1@species
#> [1] "rat"
rat1@sex
#> [1] "M"