View source: R/compute_scale.R
compute_scale | R Documentation |
Computes the average of a set of source values and transforms the result from the source range to the target range. For example, for calculating the average of a set of questionnaire response scores and re-coding the average response to obtain a subscale score.
compute_scale(
source,
source_range = NULL,
target_range = NULL,
flip_direction = FALSE,
min_n = 1
)
source |
A vector of values to be scaled A numeric vector is expected. |
source_range |
The permitted source range A numeric vector containing two elements is expected, representing the
lower and upper bounds of the permitted source range. Alternatively, if no
argument is specified for |
target_range |
The target range A numeric vector containing two elements is expected, representing the
lower and upper bounds of the target range. Alternatively, if no
argument is specified for |
flip_direction |
Flip direction of the scale? The transformed values will be reversed within the target range, e.g. within the range 0 to 100, 25 would be reversed to 75. This argument will be ignored if Default: Permitted Values: |
min_n |
Minimum number of values for computation The minimum number of non-missing values in source for the computation to
be carried out. If the number of non-missing values is below A positive integer is expected. Default: 1 |
Returns a numeric value. If source contains less than min_n
values,
the result is set to NA
. If source_range
and target_range
aren't
specified, the mean will be computed without any transformation being
performed.
The average of source transformed to the target range or NA
if
source doesn't contain min_n
values.
BDS-Findings Functions that returns a vector:
compute_bmi()
,
compute_bsa()
,
compute_egfr()
,
compute_framingham()
,
compute_map()
,
compute_qtc()
,
compute_qual_imputation()
,
compute_qual_imputation_dec()
,
compute_rr()
compute_scale(
source = c(1, 4, 3, 5),
source_range = c(1, 5),
target_range = c(0, 100),
flip_direction = TRUE,
min_n = 3
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.