Learn R Programming

spatstat.utils (version 3.1-2)

percentage: Convert Fraction to Percentage

Description

This is a programmer's utility which converts a fraction to a percentage and encodes the percentage as a character string.

Usage

percentage(x, digits = 3)

Value

A character string.

Arguments

x

Either a single number, or a logical vector.

digits

Number of digits accuracy.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

Details

If x is a single number, it should be a fraction between 0 and 1. It will be converted to a percentage and then converted to a character string followed by the percentage symbol.

If x is a logical vector, the fraction of values which are TRUE will be computed, and used to determine the percentage.

Examples

Run this code
percentage(1/3)
percentage(runif(20) > 0.2)

Run the code above in your browser using DataLab