I apologise if the answer is simple; I'm new to R but couldn't find a solution
I have a data frame, and my column of interest ('subjects') has a list of words in each row.
title subject
----- -----------------------------------------------
A c("health sciences", "life sciences")
B c("biochemistry", "medicine", "life sciences")
C c("physics and astronomy", "mathematics")
I want to replace (and therefore classify) all biology-related words for each title with "biology". So basically, if any title has a list of subjects that are biology-related, then their subject will be replaced with the much more simple 'biology'.
So that my data frame looks like this:
title subject
----- -----------------------------------------------
A biology
B biology
C c("physics and astronomy", "mathematics")
How would I replace all words beginning with key prefixes (such as "bio", "health", "med", life" etc) to 'biology' ?