Hitung barisan sekitar n+1 nilai 'bulat' dengan jarak yang sama yang mencakup rentang nilai dalam x. Nilainya dipilih sedemikian rupa sehingga menjadi 1, 2, atau 5 kali pangkat 10.
pretty(x, …)<p></p><p># S3 method for default
pretty(x, n = 5, min.n = n %/% 3, shrink.sml = 0.75,
high.u.bias = 1.5, u5.bias = .5 + 1.5*high.u.bias,
eps.correct = 0, …)</p>
| Parameter | Deskripsi |
|---|---|
x |
an object coercible to numeric by as.numeric. |
n |
integer giving the desired number of intervals. Non-integer values are rounded down. |
min.n |
nonnegative integer giving the minimal number of intervals. If min.n == 0, pretty(.) may return a single value. |
shrink.sml |
positive number, a factor (smaller than one) by which a default scale is shrunk in the case when range(x) is very small (usually 0). |
high.u.bias |
non-negative numeric, typically \(> 1\). The interval unit is determined as {1,2,5,10} times b, a power of 10. Larger high.u.bias values favor larger units. |
u5.bias |
non-negative numeric multiplier favoring factor 5 over 2. Default and ‘optimal’: u5.bias = .5 + 1.5*high.u.bias. |
eps.correct |
integer code, one of {0,1,2}. If non-0, an epsilon correction is made at the boundaries such that the result boundaries will be outside range(x); in the small case, the correction is only done if eps.correct >= 2. |
… |
further arguments for methods. |
# NOT RUN {
pretty(1:15) # 0 2 4 6 8 10 12 14 16
pretty(1:15, h = 2) # 0 5 10 15
pretty(1:15, n = 4) # 0 5 10 15
pretty(1:15 * 2) # 0 5 10 15 20 25 30
pretty(1:20) # 0 5 10 15 20
pretty(1:20, n = 2) # 0 10 20
pretty(1:20, n = 10) # 0 2 4 ... 20
for(k in 5:11) {
cat("k=", k, ": "); print(diff(range(pretty(100 + c(0, pi*10^-k)))))}
##-- more bizarre, when min(x) == max(x):
pretty(pi)
add.names <- function(v) { names(v) <- paste(v); v}
utils::str(lapply(add.names(-10:20), pretty))
utils::str(lapply(add.names(0:20), pretty, min.n = 0))
sapply( add.names(0:20), pretty, min.n = 4)
pretty(1.234e100)
pretty(1001.1001)
pretty(1001.1001, shrink = 0.2)
for(k in -7:3)
cat("shrink=", formatC(2^k, width = 9),":",
formatC(pretty(1001.1001, shrink.sml = 2^k), width = 6),"\n")
# }