convClock2Pos: Clock digits to text position and direction

Description Usage Arguments Details Value Author(s) Examples

Description

Converts text postion from clock digits to vector (horizontal, vertical, direction). It was inspired by Stata, and will be useful when applying recharts functions.

Usage

1
2
3

Arguments

pos

integer 0-25, clock digits.

drop

logical, whether coerce the result to vector when pos lengths 1. Default TRUE.

unname

logical, whether unname the result. Default TRUE.

...

other arguments

Details

The function is designed to map clock digits to the 3*3 grids of the lyaout. The corresponding position vectors (horizontal, vertical, direction) to the clock integers are as follows.

0-12 referes to:

the favorable position definitions on the clock

11(l, t, h) 12(c, t, h) 1(r, t, h)
10(l, t, v) 2(r, t, v)
9(l, c, v) 0(c, c, h) 3(r, c, v)
8(l, b, v) 4(r, b, v)
7(l, b, h) 6(c, b, h) 5(r, b, h)
13-25 refers to:

the same position as 0-12, with the direction reverted

23(l, t, v) 24(c, t, v) 13(r, t, v)
22(l, t, h) 14(r, t, h)
21(l, c, h) 25(c, c, v) 15(r, c, h)
20(l, b, h) 16(r, b, h)
19(l, b, v) 18(c, b, v) 17(r, b, v)

To make it more intuitive, please check the charts below: clock_pos.png
Note: "=" refers to horizontal direction, "||" refers to vertical direction.

Value

A vector or 3-column matrix of horizontal (x-alignment), vertical (y-alignment) and direction (direction).

Author(s)

Yiying Wang, wangy@aetna.com

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
convClock2Pos(2) ## returns c("right", "top", "vertical")

clock_to_pos(2:3, unname=FALSE)  # returns
#   horizontal  vertical  direction 
# 2 "right"     "top"     "vertical"
# 3 "right"     "center"  "vertical"

## End(Not run)

madlogos/aseskit documentation built on June 26, 2019, 12:17 a.m.