Skip to contents

Multiplies columns row by row, divides by a constant and optionally rounds (half to even), for example a count from a total and a percentage.

Usage

PlotDataProduct(data, columns, divide = 1, round = FALSE, into = "value")

Arguments

data

A data frame.

columns

Columns to multiply, in order.

divide

Divisor applied after the product.

round

Round to whole numbers.

into

Name of the new column.

Value

data with the new column.

Examples

PlotDataProduct(data.frame(n = c(44, 2), pct = c(54.5454545, 50)), c("n", "pct"),
                divide = 100, round = TRUE, into = "k")
#>    n      pct  k
#> 1 44 54.54545 24
#> 2  2 50.00000  1