get_browsers: Parse a vector of User Agent strings to distinguish browsers...

Description Usage Arguments Value Author(s) Examples

View source: R/get_browsers.R

Description

Parse a vector of User Agent strings and return a binary vector identifying browsers (1 = browser, 0 = web application).

Usage

1
get_browsers(ua_strings, verbose = FALSE)

Arguments

ua_strings

A vector of User Agent strings. Note that missing values cannot be parsed and a vector with NA elements will generate an error.

verbose

If verbose = TRUE, returns a dataframe with detailed output. This information can be used for customized classification based on User Agent strings. Note that this is effectively a wrapper for uaparserjs (https://github.com/hrbrmstr/uaparserjs) and some columns in this dataframe may be missing as User Agent strings are difficult to parse consistently. uaparserjs relies on the list of User Agent strings in the YAML file available from uap-core (https://github.com/ua-parser/uap-core).

Value

Binary vector the same length as ua_strings (default). If verbose = TRUE, a dataframe with nrows the same as vector length and 10 columns of detailed information parsed by uaparserjs.

Author(s)

Kyle Peyton <kyle.peyton@yale.edu>

Examples

1
2
3
4
5
6
7
data(agents)

## Extract binary vector (1 = browser; 0 = web application)
browsers <- get_browsers(ua_strings = agents)

## proportion of "attentive" respondents (those not coming from web apps)
mean(browsers)

kylepeyton/attentive documentation built on Jan. 1, 2021, 8:16 a.m.