Suppose I have the following data frame:
table<-data.frame(col1=c('4.3 automatic version 1', '3.2 manual version 2',
'2.3 version 1', '9.0 version 6'),
col2=c('ite auto version 2', 'ite version 3', '2.5 manual version 2',
'vserion auto 5'))
col1 col2
1 4.3 automatic version 1 ite auto version 2
2 3.2 manual version 2 ite version 3
3 2.3 version 1 2.5 manual version 2
4 9.0 version 6 vserion auto 5
I want to add a column with values of only 'automatic' or 'manual', based on the contents of columns 1 and 2. If col1 or col2 includes some word like either 'auto' or 'automatic' then col3 would be 'automatic'. If col1 or col2 is like 'manual' then col3 would be 'manual', like this:
col1 col2 col3
1 4.3 automatic version 1 ite auto version 2 automatic
2 3.2 manual version 2 ite version 3 manual
3 2.3 version 1 2.5 manual version 2 manual
4 9.0 version 6 vserion auto 5 automatic
auto
ormanual
), or more open ended (auto, manual, neither, both, other...) – Mark Miller