mult_by: Multiply selected vectors by a constant

Description Usage Arguments Value Examples

View source: R/short_generic.R

Description

Multiply a single vector or selected vectors in a dataframe by a fixed constant value. Vectors must be either numeric or integer.

Usage

1
mult_by(dat, mult_value)

Arguments

dat

a dataframe with only integer or numeric vectors

mult_value

A numeric or integer value to use as a multiplier

Value

A vector, or dataframe dat with specified columns multiplied by mult_value.

Examples

1
2
3
4
5
6
7
# Create example dataframe
fish_lengths = tibble::tibble(species = c("coho", "coho", "chin", "pink"),
                              fork_length = c(650, 580, 804, NA),
                              total_length = c(660, 589, 815, 450))

# Multiply last two columns by 0.1
fish_lengths[,2:3] = mult_by(fish_lengths[,2:3], 0.1)

arestrom/remisc documentation built on July 16, 2020, 8:48 a.m.