scale01 | R Documentation |
This function normalises a vector to be between 0 and 1. The minimum is substracted from a sample and the result is divided by the range of the vector. As used in Soliveres 2016. NA values are ignored.
\frac{ x - min(x) }{ max(x) - min(x) } = \frac{x - min(x)}{range(x)}
scale01(x)
x |
an input vector of values to be scaled. |
a vector of scaled values to be between 0 and 1.
x = sample(-100:100, 50) # create sample
normalized = (x-min(x))/(max(x)-min(x)) # normalized Data
par(mfrow=c(1,2)) # plot both example data and normalized data
plot(x)
plot(normalized) # the shape is not affected, only the range changed
# with data.table:
datatable[, (mysubset) := lapply(.SD, function(cols) calc_presenceabsence(cols, treshold=treshold, type = "max5")),.SDcols=mysubset]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.