Service Line Grouping with {healthyR}


Steven P. Sanderson II, MPH


January 27, 2023


Healthcare data analysis can be a complex and time-consuming task, but it doesn’t have to be. Meet {healthyR}, your new go-to R package for all things healthcare data analysis. With {healthyR}, you can easily and efficiently analyze your healthcare data, and make sense of the information it contains.

One of the key features of {healthyR} is the service_line_augment() function. This function is designed to help you quickly and easily append a vector to a data.frame or tibble that is passed to the .data parameter. In order to use this function, you will need a data.frame or tibble with a principal diagnosis column, a principal procedure column, and a column for the DRG number. These are needed so that the function can join the dx_cc_mapping and px_cc_mapping columns to provide the service line.

The service_line_augment() function is especially useful for analyzing healthcare data that is coded using ICD Version 10. This version of the ICD coding system is widely used in the healthcare industry, and the service_line_augment() function is specifically designed to work with it. With this function, you can quickly and easily append a vector to your data.frame or tibble that provides the service line for each visit.

In addition to the service_line_augment() function, {healthyR} also includes a wide range of other useful tools and functions for healthcare data analysis. Whether you’re looking to analyze claims data, clinical data, or any other type of healthcare data, {healthyR} has you covered.

So why wait? Download {healthyR} today and start making sense of your healthcare data! With {healthyR}, you can easily and efficiently analyze your healthcare data, and make sense of the information it contains.


Let’s take a look at the full function call.

service_line_augment(.data, .dx_col, .px_col, .drg_col)

Now let’s look at the arguments to the parameters.

  • .data - The data being passed that will be augmented by the function.
  • .dx_col - The column containing the Principal Diagnosis for the discharge.
  • .px_col - The column containing the Principal Coded Procedure for the discharge. It is possible that this could be blank.
  • .drg_col - The DRG Number coded to the inpatient discharge.

Now for some examples.


First if you have not already, install {healthyR}


Here we go.


df <- data.frame(
  dx_col = "F10.10",
  px_col = NA,
  drg_col = "896"

  .data = df,
  .dx_col = dx_col,
  .px_col = px_col,
  .drg_col = drg_col
# A tibble: 1 × 4
  dx_col px_col drg_col service_line 
  <chr>  <lgl>  <chr>   <chr>        
1 F10.10 NA     896     alcohol_abuse