Skip to contents

When displaying information in a pull down this function can be used to sort those options.

Usage

FM_pretty_sort(unsrt_data)

Arguments

unsrt_data

Unsorted data.

Value

sorted data

Examples

# This is the full path to a test data file:
data_file_local  =  system.file(package="formods", "test_data", "TEST_DATA.xlsx")
# Excel files need a sheet specification:
sheet           = "DATA"
# We will also attach the sheets along with it
df = readxl::read_excel(path=data_file_local, sheet=sheet)
# Regular sorting:
sort(unique(df$Cohort))
#>  [1] "MD 10 mg IV"  "MD 10 mg SC"  "MD 100 mg IV" "MD 100 mg SC" "MD 3 mg IV"  
#>  [6] "MD 3 mg SC"   "MD 30 mg IV"  "MD 30 mg SC"  "MD 300 mg IV" "MD 300 mg SC"
#> [11] "MD 500 mg IV" "MD 500 mg SC" "SD 10 mg IV"  "SD 100 mg IV" "SD 3 mg IV"  
#> [16] "SD 30 mg IV"  "SD 300 mg IV" "SD 500 mg IV"
FM_pretty_sort(unique(df$Cohort))
#>  [1] "MD 3 mg IV"   "MD 3 mg SC"   "MD 10 mg IV"  "MD 10 mg SC"  "MD 30 mg IV" 
#>  [6] "MD 30 mg SC"  "MD 100 mg IV" "MD 100 mg SC" "MD 300 mg IV" "MD 300 mg SC"
#> [11] "MD 500 mg IV" "MD 500 mg SC" "SD 3 mg IV"   "SD 10 mg IV"  "SD 30 mg IV" 
#> [16] "SD 100 mg IV" "SD 300 mg IV" "SD 500 mg IV"