fnRound: A function to round values in accordance with PSMD policy

Description Usage Arguments Author(s) Examples

Description

fnRound will round numeric values in accordance with PSMD policy. The policy (as at August 2016) proposes the use of the asymmetric round-half-up method (arithmetic rounding). This method rounds values at or above the midpoint away from zero and values below the midpoint towards zero to the closest required decimal place.

For example, when rounded to two decimal places values of 1.000 to 1.004 become 1.00 and values of 1.005 to 1.009 become 1.01. This applies irrespective of a number's sign so that values of -1.000 to -1.004 become -1.00 and values of -1.005 to -1.009 become -1.01.

Adapted from an anonymous post at Statistically Significant; http://alandgraf.blogspot.co.uk/2012/06/rounding-in-r.html

Usage

1
fnRound(x, n)

Arguments

x

x is the numeric value or variable to be rounded

n

n is the number of decimal places required. Trailing zeroes will be excluded.

Author(s)

Dr Daniel Zahra, e:psychometrics@plymouth.ac.uk

Examples

1
fnRound(13.436765,2) will return 13.44

PSMD-Psychometrics/-old-psychometricsPSMD-old- documentation built on May 30, 2019, 4:19 p.m.