I am trying to create a new column based on a existing column that uses pattern matching. The existing column is a user agent field such as
"Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10"
I want to create a new column that uses pattern matching to identify what device is.
-So if user_agent like '%iPad%' and user_agent like '%WebKit%' then device is iPad. -if user agent user_agent like '%Android%' and user_agent not like '%Mobile%' then device is an android - if the (user_agent like '%Silk%' and user_agent like '%WebKit%') then device is kindle -if (user_agent like '%Playbook%') then device is Other
I want to try using the mutate function in dplyr to create the new column but need help with how to structure the regular expression
i.e mutate(data,device = ....)