Which package/function do I use to replace entries containing a certain set of letters with a 0 or 1?

ساخت وبلاگ

Vote count: 0

Sorry if it's a dumb question, but I'm not sure what keywords to use to find the answer so nothing I get is quite what I'm looking for.

I have a column: df$infecting_agent. The entries there are things like "staphylococcus" "bacteria" "virus" "bacterial", etc.

I want two new columns: df$bacteria and df$virus

I want all observations to have a "1" for bacteria if the diagnoses entry contains "bact" or "cocc" or "staph" where anything is allowed before or after what's in quotes. I'll do similar for the virus column, many observations will have a 1 in both columns.

Can someone tell me what package to use or at least what the "lingo" is I should be using to search for my problem? I tried variations of "replace string with 0 or 1 in R" but I don't think I'm getting anything relevant.

Thank you all!

asked 1 min ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 316 تاريخ : سه شنبه 22 فروردين 1396 ساعت: 7:24