Description Usage Arguments Details Value Examples
Convenience function that uses derive_metric()
and the scales::rescale()
function.
By default, rescales each individual measured value from 0 to 1 using
the range from minmum to maximum value.
1 | scale_metric(.df, .name, .to = c(0, 1), ...)
|
.df |
A data frame containing tidycyte data. |
.name |
< |
.to |
Numeric vector of the min and max final rescaled range. Defaults to |
... |
< |
Note that this does not scale according to the mean of
the observations but to the individual measured values themselves. Hence if using summary_stats()
,
the maximum mean value would be expected to be less than 1. If normalization is needed after
using summary_stats()
, it can be performed manually.
This function overwrites the original metric. If a new metric name is desired, the original metric should first be copied to a new metric name. See example below.
A dataframe with rescaled metrics
1 2 3 4 5 6 | # copy to new name rather than the original name
df %>% derive_metric(mAzalea_scaled, mAzalea) %>%
scale_metric(mAzalea_scaled)
# rescales mAzalea metric in place, overwriting original values
df %>% scale_metric(mAzalea)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.