This function maps a set of values to a range of integers (from 1 to a positive integer passed as an argument).
scaleWithin(x, n = 100, mn = min(x), mx = max(x))
| x | a numeric object of type |
|---|---|
| n | an integer designing The number of scaled values (between 1 and |
| mn | minimum value ( |
| mx | maximum value ( |
A numeric vector
This function was originally created to ease the creation of custom color
scales. In such context, it is common practice to define a minium and a
maximum for the set of values to be displayed values as well as a number of
color to be used in the color scale (n). This is exactly what
scaleWithin() does: minimum and maximum are by default the ones of the set
of values x but can also be set using mn and mx in which case values
below mn will be set to mn (and thus to 1 in the output) and values
above mx will be set to mx (and thus to 1 in the output). Finally, the
number of colors to be used used in is given by n.
#> [1] 10 13 13 12 9 12 15 14 5 9 13 15 5 9 12 9 5 6 9 13#> [,1] [,2] #> [1,] 1 21 #> [2,] 21 41 #> [3,] 21 1 #> [4,] 11 1 #> [5,] 1 11 #> [6,] 11 1 #> [7,] 41 1 #> [8,] 31 1 #> [9,] 1 1 #> [10,] 1 21