Learn R Programming

icesTAF (version 3.6.0)

div: Divide Columns

Description

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

Usage

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

Value

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

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().

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.

icesTAF-package gives an overview of the package.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab