This function uses a combination of variable class, number of unique values, and regular expression matching to extract HR / organisational attributes from a data frame.

extract_hr(data, max_unique = 50, exclude_constants = TRUE, return = "names")

Arguments

data

A data frame to be passed through.

max_unique

A numeric value representing the maximum number of unique values to accept for an HR attribute. Defaults to 50.

exclude_constants

Logical value to specify whether single-value HR attributes are to be excluded. Defaults to TRUE.

return

String specifying what to return. This must be one of the following strings:

  • "names"

  • "vars"

See Value for more information.

Value

A different output is returned depending on the value passed to the return

argument:

  • "names": character vector identifying all the names of HR variables present in the data.

  • "vars": data frame containing all the columns of HR variables present in the data.

Examples

sq_data %>% extract_hr(return = "names")
#> [1] "FunctionType"     "LevelDesignation" "Organization"     "IsActive"        

sq_data %>% extract_hr(return = "vars")
#> # A tibble: 13,442 × 4
#>    FunctionType LevelDesignation Organization     IsActive
#>    <chr>        <chr>            <chr>            <lgl>   
#>  1 G_and_A      Junior IC        Customer Service TRUE    
#>  2 G_and_A      Junior IC        Customer Service TRUE    
#>  3 G_and_A      Junior IC        Customer Service TRUE    
#>  4 G_and_A      Junior IC        Customer Service TRUE    
#>  5 G_and_A      Junior IC        Customer Service TRUE    
#>  6 G_and_A      Junior IC        Customer Service TRUE    
#>  7 G_and_A      Junior IC        Customer Service TRUE    
#>  8 G_and_A      Junior IC        Customer Service TRUE    
#>  9 G_and_A      Junior IC        Customer Service TRUE    
#> 10 G_and_A      Junior IC        Customer Service TRUE    
#> # … with 13,432 more rows