Hello, I'm struggling with some data I have - I have multiple columns of blood results corresponding to different units and I'd like to make a single column of values in the same units.
Dummy data:
Units Other Score Score2
Not measured
ug/L 29.9
ng/L 5
ng/L 109
ng/L
Not measured
ng/L 5
ng/L 2
ng/L
ng/L
ng/L
ng/L
ng/L
Other pg/ml 11.3
What I'd like to do is convert all scores to ug/L. This will involve transforming ng/L to ug/L (x 0.001) and converting pg/ml to ug/L (x 0.001). What I would like at the end is:
Units Other Score Score2 Score_ug/L
Not measured
ug/L 29.9 29.9
ng/L 5 0.005
ng/L 109 0.109
ng/L
Not measured
ng/L 5 0.005
ng/L 2 0.002
ng/L
ng/L
ng/L
ng/L
ng/L
Other pg/ml 11.3 0.0113
I'd like to retain blank rows and also the rows that have "Not measured".
I don't know if this is something dplyr is capable of? What I can't manage to do is mutate the units column when it varies by unit and some units aren't measured and other units are in a separate column. I tried to use the summarise across columns function, but I became unstuck when the last row had units in a different column :-(.
If anyone can point me in the right direction, I'd be extremely grateful.
Pls go easy, I'm a clinician not a bioinformatician....
Could you please give us some representative data to work with?
Can you not see the data in the post? This is representative of the dataset... ! Values have been changed, but otherwise this is a snapshot of what I'm working with. Blank lines need to be retained because there are other (unshown) columns with values in. Dataset is over 1000 columns, so can't possibly share. I'm only showing the relevant bits.
Apologies. Is that completely representative? Are there any aspects to the data that isn't addressed by the example in your OP?
For what I need it is completely representative. If it helps, you can assume every row has a unique ID. Otherwise it is unfortunately what I'm dealing with as the output!
To share your data, please paste in the results of
dput(head(data))
into your original question. Thanks.