fv_percent_lead: Percent Difference

Description Usage Arguments Value Examples

View source: R/fv_percent_lead.R

Description

fv_percent_lead - Convert a vector of values to percent relative to prior value in the vector (i.e., T2/T1).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
fv_percent_lead(x, digits = getOption("numformdigits"), ...)

fv_percent_lead_fixed_relative(
  x,
  fixed.relative = 1,
  digits = getOption("numformdigits"),
  ...
)

ffv_percent_lead(...)

ffv_percent_lead_fixed_relative(...)

Arguments

x

A numeric vector.

digits

The number of digits to use. Defaults to 1. Can be set globally via: options(numformdigits = n) where n is the number of digits beyond the decimal point to include.

fixed.relative

The position of the element to be used for comparison. Default is the first element.

...

Other arguments passed to f_prop2percent.

Value

Returns a string of publication ready relative percent differences.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set.seed(10)
x <- sample(1:10)

data.frame(
    original = x,
    perc_change = fv_percent_lead(x)
)

## Not run: 
library(dplyr)

CO2 %>%
    group_by(Plant) %>%
    mutate(
        `Percent` = fv_percent(conc),
        `Percent Diff` = fv_percent_diff(conc),
        `Percent Relative` = fv_percent_lead(conc)
    ) %>%
    print(n=Inf)

CO2 %>%
    group_by(Type, Treatment) %>%
    mutate(
        `Percent` = fv_percent(conc),
        `Percent Diff` = fv_percent_diff(conc),
        `Percent Relative` = fv_percent_lead(conc)
    ) %>%
    print(n=Inf)

## End(Not run)

numform documentation built on Oct. 10, 2021, 1:10 a.m.