pradeep chintapalli
pradeep chintapalli

Reputation: 1

Extracting different specified words from a particular string

I have a column in my excel which i want to modify. Ill be needing the following

If a particular column has words like "CAP","Caps","caps","Cap","cap","CAPS" then an empty column should say "caps" or else "Default".

For Example:

Description Type Cap for DPRD caps Pickup cap change GLS criticality> caps Raise Caps for CGN9 caps Place TT Pads on DHL Lanes Default Noncon Caps for MXP8 caps

I am working in excel and not sure if this can be acheived through excel or with R.

Thanks for the help.

Upvotes: 0

Views: 41

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522541

Use grepl for a base R option:

df$label <- ifelse(grepl("caps?", df$col, ignore.case=TRUE), "caps", "Default")

Upvotes: 1

Related Questions