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] "FunctionType"        "SupervisorIndicator" "Level"              
#> [4] "Organization"        "LevelDesignation"   

pq_data %>% extract_hr(return = "vars")
#> # A tibble: 6,900 × 5
#>    FunctionType SupervisorIndicator Level  Organization LevelDesignation
#>    <chr>        <chr>               <chr>  <chr>        <chr>           
#>  1 Specialist   Manager             Level3 IT           Senior IC       
#>  2 Consultant   Manager             Level2 Legal        Senior Manager  
#>  3 Advisor      Manager             Level4 Legal        Junior IC       
#>  4 Consultant   Manager             Level1 HR           Executive       
#>  5 Technician   Manager             Level1 Finance      Executive       
#>  6 Advisor      Manager             Level3 Finance      Senior IC       
#>  7 Specialist   IC                  Level4 Finance      Junior IC       
#>  8 Advisor      Manager             Level3 IT           Senior IC       
#>  9 Manager      Manager             Level3 HR           Senior IC       
#> 10 Advisor      Manager             Level1 IT           Executive       
#> # ℹ 6,890 more rows