Learn R Programming

stevemisc (version 1.8.0)

make_perclab: Make Percentage Label for Proportion and Add Percentage Sign

Description

make_perclab() takes a proportion, multiplies it by 100, optionally rounds it, and pastes a percentage sign next to it.

Usage

make_perclab(x, d = 2)

Value

The function takes a proportion, multiplies it by 100, (optionally) rounds it to a set decimal point, and pastes a percentage sign next to it.

Arguments

x

a numeric vector

d

digits to round. Defaults to 2.

Details

This function is useful if you're modeling proportions in something like a bar chart (for which proportions are more flexible) but want to label each bar as a percentage. The function here is mostly cosmetic.

Examples

Run this code

x <- runif(100)
make_perclab(x)

Run the code above in your browser using DataLab