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.
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?
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/RStudio/com...