resc.val: R function to rescale the values of a dataset between a...

resc.valR Documentation

R function to rescale the values of a dataset between a minimum and a maximum set by the user

Description

The function allows to rescale the values of a dataset between a minimum and a maximum that are specified by the user. In doing that, it allows to preserve the shape of the distribution of the original data.

Usage

resc.val(x, min.v = 0, max.v = 100)

Arguments

x

Vector containing the values to be rescaled.

min.v

Minimum value of the rescaled dataset (0 by default).

max.v

Maximum value of the rescaled dataset (100 by default).

Details

The function produces two density charts representing the distribution of the original and of the rescaled dataset. It also returns a dataframe storing the original and rescaled values.

Examples

#generate a random dataset of size 30, normally distributed with mean 1000 and
#standard deviation 10
dataset <- rnorm(30, 1000,10)

#rescale the dataset to be constrained between 10 and 100
resc.val(dataset, min.v=10, max.v=100)


GmAMisc documentation built on March 18, 2022, 6:32 p.m.