add_row_percent: Calculate row percentages for a set of columns in a dataframe...

Description Usage Arguments Value

View source: R/percent.R

Description

Calculate row percentages for a set of columns in a dataframe and add them to the dataframe

Usage

1
add_row_percent(data, from = 2, to = ncol(data), na.rm = FALSE, prefix = "rp_")

Arguments

data

A dataframe containing columns of numerical data to be expressed as row percentages.

from

The number or name of the column from which row percentages are calculated. The default is 2, assuming one column for row labels. Use 1 if there are no preceding data columns.

to

The number or name of the column to which row percentages are calculated. The default is ncol(data), which means row percentages are calculated across all remaining columms in the dataframe.

na.rm

A boolean which if TRUE ignores NAs in calculating percentages. The default value is FALSE.

prefix

A string prefix to add to the column names to identify their percentage equivalents. The default is "rp_"

Value

The input data with additional columns containing row percentages for columns specified by from and to.


olihawkins/cltools documentation built on Sept. 14, 2020, 7:25 a.m.