I am a bit confused on how to perform this form of data wrangling, as I am new to R coding. My goal is to match subjectID information to this large data set that I have that have more rows than that of the subjectID data. This is because the large data has more than one session with a cohort of subjects. For example,Subject A would have data that has a row name SubjectA-01, SubjectA-02, etc.
My goal is to match SubjectID name to the large data set, such that I can add new columns (sex, age, BMI, etc.) as columns correlating to the data.
We can call this dataframe SubjectID <-
Subject ID | Sex | Age |
---|---|---|
SubjectA | M | 32 |
SubjectB | F | 16 |
And I want to use this information to match the beginning keyword in this matrix. Lets call this data set as BioResults.
SampleID | Blood Result |
---|---|
SubjectA-01 | 2.34 |
SubjectA-02 | 2.55 |
SubjectB-12 | 3.56 |
My goal is to make a new data set that looks like this:
SampleID | Blood Result | Sex | Age |
---|---|---|---|
SubjectA-01 | 2.34 | M | 32 |
SubjectA-02 | 2.55 | M | 32 |
SubjectB-12 | 3.56 | F | 16 |
What would be the best way to achieve this? I would appreciate any help as I am still new to this coding language. Thank you!