This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Should I be trying to write a loop to solve my problem?
Post Body

https://preview.redd.it/q2g7zh2vvb8b1.png?width=1347&format=png&auto=webp&s=2fac1d266c07f0e343ab7ac35ae7d7c82333b43f

Hi All, Im currently cleaning up some rather dirty blood culture data ( pun intended) and its veering away from my comfort zone in bioinformatics into basic data manipulation and im starting to struggle, as im not entirely sure the best way to approach this.

As you can see in the above df, I have a row with a string of data - this is the highly cleaned up version( the S,R or I before the : indicates sensitive, resistant or intermediate, and the letters afterwards stand for the antibiotic).

What I want, is to extract those S,R,I data for each abx in a row and where relevant paste that information into a corresponding col to facilitate analysis. I have created new cols with the names of each antibiotic.

My pseudocode is some sort of loop:

for each row in df, split the string in the df$concat by ","
then split each new item(?) by ":"
for each second element in these new pairs, find the matching colname in df and paste the first element into the corresponding row
then move onto the next element and repeat 

These seems very clunky and will be hard to write I think, so Im fairly sure Im missing some basic tidyverse solution - whats the best approach here?

Author
Account Strength
90%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,527
Link Karma
107
Comment Karma
4,420
Profile updated: 1 day ago
Posts updated: 5 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago