I have this dataframe:
a <- c(1,2,3,4, 5)
b <- c('Software Engineer', 'Data Engineer', 'HR Officer', 'Marketing Manager', 'Computer Engineer')
names(df) <- c('ID', 'Jobs')
I want to group languages in some categories, If each job description contains the "Software", "Data" or "Computer", then the category for this job is "IT", if not the category would be "OTH". The result should look like this:
ID Jobs Category
1 Software Engineer IT
2 Data Engineer IT
3 HR Officer OTH
4 Marketing Manager OTH
5 Computer Engineer IT
In Python I can use these code df["Jobs"].str.contains("Software|Data|Computer", na = False) combines with np.select to get the Category. However I don't know how to do it in R, please give me some advice to solve this problem.