View source: R/helper_functions.R
rescale_to_int | R Documentation |
rescale_to_int
rescales the non-zero elements of
real-valued numeric vectors or matrices to integers in the closed
interval [1, max
]. Any zero-valued elements are left unchanged.
rescale_to_int(x, max, colwise = TRUE)
x |
numeric matrix or vector of non-negative real numbers. |
max |
the value of largest element in the rescaled integer-valued vector. |
colwise |
(logical) rescale the matrix by column if |
rescale_to_int
returns a matrix of integers corresponding
to x
in which smallest non-zero element in each column/row
is 1 and the largest element is max
. Any elements having value zero
are unchanged. If x
is a vector then the result is an r x 1
matrix, where r is the number of elements in x
. Otherwise
the result is a r x c matrix where c is the number of
columns in x
.
rescale
x <- c(0.55, 1.21, 0.94, 0, 0.13) rescale_to_int(x, max = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.