Learn R Programming

cursory (version 1.0.0)

Npct: Combine count with a percent

Description

Combine count with a percent

Usage

Npct(x, n, ...)

# S4 method for logical,missing Npct(x, n, ...)

# S4 method for logical,logical Npct(x, n, ...)

# S4 method for integer,integer Npct(x, n, ...)

# S4 method for numeric,numeric Npct(x, n, ...)

Arguments

x

count or object to count

n

see methods.

...

formatting arguments for formatting the percent. See format.percent.

Value

A character vector formatted with number and percent of successes.

Methods (by class)

  • x = logical,n = missing: Count and give percent of TRUE from a logical vector.

  • x = logical,n = logical: Count and percent of a logical filtered by a second logical.

  • x = integer,n = integer: Provided with count(s) of cases and total(s)

  • x = numeric,n = numeric: Provided the actual count and the percent.

Examples

Run this code
# NOT RUN {
# Vector of cases only.
Npct(c(TRUE, FALSE, TRUE))

# Cases with indices
Npct( c(TRUE,FALSE,TRUE,FALSE,TRUE), c(TRUE,TRUE,TRUE,FALSE,FALSE))

# Successes/Total
Npct(2L, 3L)

# Count + percent directly, count must be integerish.
Npct(2, 2/3)

# }

Run the code above in your browser using DataLab