I am working with log data from a website and I have one variable indicating the browser, e.g.,
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
for PC
or
Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1
for Mobile.
I know that for Python there is a library to do this, is there an equivalent solution for R?
I tried the uaparserjs package and it gives out things like device family, device brand etc, but how can I create a variable indicating the device in the categories PC, Mobile, or Tablet?
library(uaparserjs)
ua_parse("Mozilla/5.0 (Linux; Android 10; HRY-LX1T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.105 Mobile Safari/537.36")
# A tibble: 1 x 10
userAgent ua.family ua.major ua.minor ua.patch os.family os.major device.family device.brand device.model
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 Mozilla/5.0 (Linux; Android 10; HRY-LX1T) Appl~ Chrome Mo~ 89 0 4389 Android 10 HRY-LX1T Generic_Andr~ HRY-LX1T
Ideally, I would be able to detect PC vs. mobile vs. tablet.