div: Divide Columns

Description Usage Arguments Value Note See Also Examples

View source: R/div.R

Description

Divide column values in a data frame with a common number.

Usage

1
div(x, cols, by = 1000, grep = FALSE, ...)

Arguments

x

a data frame.

cols

column names, or column indices.

by

a number to divide with.

grep

whether cols is a regular expression.

...

passed to grep().

Value

A data frame similar to x, after dividing columns cols by the number by.

Note

Provides notation that is convenient for modifying many columns at once.

See Also

transform can also be used to recalculate column values, using a more general and verbose syntax.

grep is the underlying function used to match column names if grep is TRUE.

rnd is a similar function that rounds columns.

TAF-package gives an overview of the package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# These are equivalent:

x1 <- div(summary.taf, c("Rec","Rec_lo","Rec_hi",
                         "TSB","TSB_lo","TSB_hi",
                         "SSB","SSB_lo","SSB_hi",
                         "Removals","Removals_lo","Removals_hi"))

x2 <- div(summary.taf, "Rec|TSB|SSB|Removals", grep=TRUE)

x3 <- div(summary.taf, "Year|Fbar", grep=TRUE, invert=TRUE)

# Less reliable in scripts if columns have been added/deleted/reordered:

x4 <- div(summary.taf, 2:13)

TAF documentation built on April 7, 2021, 5:06 p.m.