Skip to contents

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.

Usage

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

pq_data %>% extract_hr(return = "names")
#> [1] "LevelDesignation"    "SupervisorIndicator" "Organization"       
#> [4] "FunctionType"        "WeekendDays"        

pq_data %>% extract_hr(return = "vars")
#> # A tibble: 1,000 × 5
#>    LevelDesignation SupervisorIndicator    Organization FunctionType WeekendDays
#>    <chr>            <chr>                  <chr>        <chr>        <chr>      
#>  1 Manager          Manager                Sales and M… G_and_A      [SUNDAY, S…
#>  2 Support          Individual Contributor Finance      Sales        [SUNDAY, S…
#>  3 Support          Individual Contributor Product      IT           [SUNDAY, S…
#>  4 Director         Manager+               Sales and M… Analytics    [SUNDAY, S…
#>  5 Support          Individual Contributor Sales and M… IT           [SUNDAY, S…
#>  6 Support          Individual Contributor HR           Engineering  [SUNDAY, S…
#>  7 Support          Individual Contributor Finance      Engineering  [SUNDAY, S…
#>  8 Support          Individual Contributor HR           Analytics    [SUNDAY, S…
#>  9 Senior IC        Individual Contributor Product      Analytics    [SUNDAY, S…
#> 10 Support          Individual Contributor Finance      Sales        [SUNDAY, S…
#> # ℹ 990 more rows