Replace entire string by one specific word.

Hi @mfherman , Thanks for the revert. I will keep a note on the best practices.

I am reading a csv file and doing column cleaning stuff on the csv as given in the code below:

raw_armed_conflicts <- read.csv('C:\\ketan\\SampleProject\\Conflicts.csv')

#Removing unwanted columns from the dataset and choosing only the necessary columns
raw_armed_conflicts <- raw_armed_conflicts[,c(1,5,6,8,16,17,22,23,28)]

#Renaming the columns legibly
names(raw_armed_conflicts)[1] <- 'event_data_id'
names(raw_armed_conflicts)[3] <- 'event_year'
names(raw_armed_conflicts)[5] <- 'event_region'
names(raw_armed_conflicts)[6] <- 'event_country'
names(raw_armed_conflicts)[7] <- 'event_latitude'
names(raw_armed_conflicts)[8] <- 'event_event_longitude'
names(raw_armed_conflicts)[9] <- 'event_fatalities'

I need to group the data in the column 'event_type'. Wherever I find 'Battle...' in the string of distinct event types, I need to replace the entire event type by only ' Battles '
Similarly if an event type contains 'Riots/Protests' replace the entire string by 'Riots'

Data for reference attached:

|data_id|event_date|year|event_type|region|country|iso3|latitude|longitude|fatalities|
|---|---|---|---|---|---|---|---|---|---|
|1892808|20-Oct-18|2018|Battle-No change of territory|Eastern Africa|Burundi|BDI|-2.8772|29.3253|4|
|1892831|20-Oct-18|2018|Violence against civilians|Middle Africa|Cameroon|CMR|5.9333|10.1667|3|
|1892860|20-Oct-18|2018|Battle-Government regains territory|Northern Africa|Egypt|EGY|31.1316|33.7984|4|
|1892861|20-Oct-18|2018|Battle-No change of territory|Northern Africa|Egypt|EGY|31.2163|34.1107|0|
|1892874|20-Oct-18|2018|Strategic development|Eastern Africa|Ethiopia|ETH|12.9667|36.2|0|
|1892875|20-Oct-18|2018|Violence against civilians|Eastern Africa|Ethiopia|ETH|10.15|36.35|6|
|1892920|20-Oct-18|2018|Battle-No change of territory|Western Africa|Mali|MLI|14.795|-1.318|1|
|1892921|20-Oct-18|2018|Violence against civilians|Western Africa|Mali|MLI|16.6314|-3.3256|0|
|1892922|20-Oct-18|2018|Riots/Protests|Western Africa|Mali|MLI|16.8425|-3.8559|1|
|1892961|20-Oct-18|2018|Violence against civilians|Western Africa|Nigeria|NGA|12.1492|12.9907|12|
|1892962|20-Oct-18|2018|Violence against civilians|Western Africa|Nigeria|NGA|11.4953|12.9688|2|
|1893075|20-Oct-18|2018|Non-violent transfer of territory|Eastern Africa|Somalia|SOM|3.0399|43.7969|0|
|1893076|20-Oct-18|2018|Riots|Eastern Africa|Somalia|SOM|8.4064|48.4819|0|
|1893282|20-Oct-18|2018|Violence against civilians|Southern Asia|Afghanistan|AFG|33.6457|62.2696|0|
|1893283|20-Oct-18|2018|Violence against civilians|Southern Asia|Afghanistan|AFG|34.5195|65.2509|6|
|1893284|20-Oct-18|2018|Strategic development|Southern Asia|Afghanistan|AFG|34.9145|65.2884|0|
|1893285|20-Oct-18|2018|Violence against civilians|Southern Asia|Afghanistan|AFG|34.3448|61.4932|0|
|1893286|20-Oct-18|2018|Battle-No change of territory|Southern Asia|Afghanistan|AFG|34.5167|69.1833|16|