Returns track percentile of the values.

emr_track.percentile(track, val, lower = TRUE)

Arguments

track

track name

val

vector of values

lower

how to calculate percentiles

Value

A vector of percentile values

Details

This function returns the percentiles of the values given in 'val' based on track data.

If 'lower' is 'TRUE' percentile indicates the relative number of track values lower than 'val'. If 'lower' is 'FALSE' percentile reflects the relative number of track values lower or equal than 'val'.

See also

Examples


emr_db.init_examples()
#> NULL

# percentiles of 30, 50
emr_track.percentile("dense_track", c(30, 50))
#> [1] 0.45 0.50

# calculate percentiles of track's earliest values in time window
emr_vtrack.create("v1",
    src = "dense_track", func = "earliest",
    time.shift = c(-5, 5)
)
emr_extract(
    c(
        "dense_track",
        "emr_track.percentile(\"dense_track\", v1, FALSE)"
    ),
    keepref = TRUE, names = c("col1", "col2")
)
#>    id time ref col1 col2
#> 1  22    1   3   13 0.20
#> 2  24    1   3   13 0.20
#> 3  25    1   0   10 0.05
#> 4  25    2   0   20 0.05
#> 5  25    2   2   22 0.05
#> 6  25    2   5   24 0.05
#> 7  25    2   6   26 0.05
#> 8  25    2   8   28 0.05
#> 9  25    3   4   34 0.05
#> 10 25    6   0   60 0.05
#> 11 25    6   2   62 0.05
#> 12 25    8   1   80 0.50
#> 13 25    8   4   84 0.50
#> 14 25    9   2   92 0.60
#> 15 25    9   4   94 0.60
#> 16 25   10   4  104 0.60
#> 17 25   12   4  124 0.70
#> 18 27   23   4  234 0.95
#> 19 27   50   0  500 1.00
#> 20 28    1   3   13 0.20