conditional_mutate: Conditional mutate function

Description Usage Arguments See Also Examples

View source: R/conditional_dplyr.R

Description

Perform mutate if condition is met. This function is a simple wrapper for mutate.

Usage

1
conditional_mutate(df1, cond, LHS, RHS)

Arguments

df1

A dataframe

cond

A logical value indicating if mutate should be performed

varName

Name of variable to create

See Also

Other conditional dplyr: conditional_filter, conditional_range_filter, conditional_select

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
mtcars %>%
  dplyr::as_tibble() %>%
  conditional_mutate(
    exists("cyl", where = .),
    LHS = cyl2,
    RHS = cyl * 2
  )

mtcars %>%
  dplyr::as_tibble() %>%
  conditional_mutate(
    exists("cyl2", where = .),
    LHS = cyl4,
    RHS = cyl2 * 2
  )

chrischizinski/huntfishapp documentation built on Sept. 7, 2020, 12:14 p.m.