Skip to contents

This function arranges and annotates a data frame based on specified types of treatment effect estimates (RR or RD). It supports different sorting options including default descending, alphabetical, and custom order. It now also handles original scale estimates when available.

This function arranges and annotates a data frame based on specified types of treatment effect estimates (RR or RD). It supports different sorting options including default descending, alphabetical, and custom order. It now also handles original scale estimates when available.

Usage

group_tab(
  df,
  type = c("RD", "RR"),
  order = c("default", "alphabetical", "custom"),
  custom_order = NULL
)

group_tab(
  df,
  type = c("RD", "RR"),
  order = c("default", "alphabetical", "custom"),
  custom_order = NULL
)

Arguments

df

Data frame containing the variables of interest, or a list containing the results dataframe and label mapping from transform_to_original_scale().

type

Type of treatment effect to analyze. Expected values are 'RR' for Risk Ratio and 'RD' for Risk Difference. Defaults to 'RD'.

order

Specifies the order in which the outcomes should be arranged. Can be 'default' for descending order of the estimate, 'alphabetical' for alphabetical order by outcome, or 'custom' for a user-defined order. Default is 'default'.

custom_order

A vector of custom ordering for the outcomes, applicable if `order` is set to 'custom'. This should be a vector containing all outcomes in the desired order.

Value

A data frame that has been arranged based on the specified order and annotated with treatment effect estimates, estimate labels, and evidence value annotations. If original scale estimates are available, these will be included in the output.

A data frame that has been arranged based on the specified order and annotated with treatment effect estimates, estimate labels, and evidence value annotations. If original scale estimates are available, these will be included in the output.

Details

The function now handles both transformed and original scale results. If original scale results are available (indicated by the presence of columns with "_original" suffix), these will be included in the output. The function also applies label mapping if provided.

The function now handles both transformed and original scale results. If original scale results are available (indicated by the presence of columns with "_original" suffix), these will be included in the output. The function also applies label mapping if provided.

Examples

# Example using Risk Ratio (RR) and default sorting
result_df <- group_tab(df = analysis_df, type = 'RR')
#> Loading required package: dplyr
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
#> Error: object 'analysis_df' not found

# Example using Risk Difference (RD) with alphabetical sorting
result_df <- group_tab(df = analysis_df, type = 'RD', order = 'alphabetical')
#> Error: object 'analysis_df' not found

# Example using custom sorting order
custom_order <- c("Outcome3", "Outcome1", "Outcome2")
result_df <- group_tab(df = analysis_df, type = 'RR', order = 'custom', custom_order = custom_order)
#> Error: object 'analysis_df' not found

# Example using output from transform_to_original_scale()
transformed_data <- transform_to_original_scale(results_df, original_df, label_mapping)
#> Error: object 'results_df' not found
result_df <- group_tab(transformed_data, type = 'RD')
#> Error: object 'transformed_data' not found

# Example using Risk Ratio (RR) and default sorting
result_df <- group_tab(df = analysis_df, type = 'RR')
#> Error: object 'analysis_df' not found

# Example using Risk Difference (RD) with alphabetical sorting
result_df <- group_tab(df = analysis_df, type = 'RD', order = 'alphabetical')
#> Error: object 'analysis_df' not found

# Example using custom sorting order
custom_order <- c("Outcome3", "Outcome1", "Outcome2")
result_df <- group_tab(df = analysis_df, type = 'RR', order = 'custom', custom_order = custom_order)
#> Error: object 'analysis_df' not found

# Example using output from transform_to_original_scale()
transformed_data <- transform_to_original_scale(results_df, original_df, label_mapping)
#> Error: object 'results_df' not found
result_df <- group_tab(transformed_data, type = 'RD')
#> Error: object 'transformed_data' not found