round_percent: Round vector of number to percentages

View source: R/round_percent.R

round_percentR Documentation

Round vector of number to percentages

Description

Rounds a vector of numeric values to percentages ensuring that they add up to 100

Usage

round_percent(x, decimals = 0L, ties = c("random", "last"))

Arguments

x

A numeric vector with non-negative values.

decimals

An integer giving the number of decimals that are used

ties

A string that is either 'random' (the default) or 'last'. Determines how to break ties. Random is random, last prefers to break ties at the last position

Details

Returns a vector of numeric values.

Value

Returns a numeric vector of the same length as x

Author(s)

Claus Ekstrom claus@rprimer.dk

Examples


f <- c(1,2,1,3,2,1,2,3,1)
round_percent(f)



MESS documentation built on Aug. 21, 2023, 1:05 a.m.

Related to round_percent in MESS...