| Type: | Package |
| Title: | Parse 'User-Agent' Strings |
| Version: | 0.4.0 |
| Date: | 2026-07-02 |
| Description: | Parses HTTP user agent strings and returns user agent, device and OS information. This is a 'V8'-backed package based on the 'ua-parser' project https://github.com/ua-parser. |
| URL: | https://github.com/gregfrog/uaparserjs |
| BugReports: | https://github.com/gregfrog/uaparserjs/issues |
| License: | Apache License 2.0 | file LICENSE |
| Suggests: | tinytest, yaml, tibble |
| Depends: | R (≥ 3.5.0) |
| Encoding: | UTF-8 |
| Imports: | progress, V8 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-01 22:19:07 UTC; greg |
| Author: | Bob Rudis [aut, cph], Greg Hunt [aut, cre, cph], Lindsey Simon [aut] (uap-core), Tobie Langel [aut] (uap-core), Colman Humphrey [ctb], Jim Vine [ctb] |
| Maintainer: | Greg Hunt <greg@firmansyah.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-02 21:50:02 UTC |
Parse 'User-Agent' Strings
Description
This package parses HTTP user agent strings and returns user agent, device and OS information. It does this by providing a wrapper around the user agent parser provided by the ua-parser project's Javascript reference parser (<https://github.com/ua-parser>)
Details
The package incorporates regular expressions and test data from the ua parser project that are copyrighted by Google and the UA Parser contributors and are used under an Apache 2 license. See the UA parser project for details.
Author(s)
Bob Rudis (@hrbrmstr) Greg Hunt
See Also
Useful links:
Parse a vector of user agents into a data frame
Description
Takes in a character vector of user agent strings and returns a data frame (classed as tibble) of parsed user agent attributes.
Usage
ua_parse(user_agents, .progress = FALSE, useNA=FALSE)
get_cache()
Arguments
user_agents |
a character vector of user agents |
.progress |
if 'TRUE' will display a progress bar in interactive mode |
useNA |
If 'TRUE' will ensure that for each user agent passed in a parsed result is returned and NA values will be returned for all attributes. The default value is FALSE for compatibility with existing behaviour. TRUE is recommended. When FALSE, NULL or zero length string user agent strings are not parsed and are not returned in the data frame and under some circumstances not all attributes are returned. |
Value
a data frame classed as tibble with columns for:
user agent string (note that with useNA=TRUE a null string is returned as an NA value not a null)
user agent family (ua.family)
major & minor versions (ua.major, ua.minor)
patch level (ua.patch)
OS family (os.family)
major & minor OS versions (os.major, os.minor)
OS patch (os.patch)
device family (device.family)
device brand (device.brand) device model (device.model)
The Family values are identified as "Other" for unrecognised or unparseable user agent strings.
When useNA is true and the tibble package is available, an actual tibble is returned.
Note
The regex YAML from uap-core is updated when the package is rebuilt. The date amd abbreviated hash of the last uap-core commit can be found in the NEWS file.
References
<https://github.com/ua-parser/uap-core/>
Examples
ua_parse(paste0("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, ",
"like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 ",
"Chrome/15.0.874.106 Safari/535.2", collapse=""))