knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(relper)
format_
functions modify an existing variable for aesthetic reasons.
The goal of format_digit
is to add zero(s) on the left of a number.
x <- c(1,4,10,12,100,2000) format_digit(x)
You can also set the argument digits
to add more zeros.
format_digit(x,digits = 4)
The goal of format_num
is to add markers to a number.
format_num(12345.67)
You can also change the markers to suit other characters.
format_num(12345.67,decimal_mark = "*",thousand_mark = "#")
Also, if you're a Brazilian like me, I made a case for making our lives easier.
format_num(12345.67,br_mark = TRUE)
The goal of format_scale
is to reescale a variable, given by:
$$y_i = (y_{\max} - y_{\min}) * \left[\frac{x_i - \min(x_i)}{\max(x)-\min(x)} \right] + y_{\min},$$ where:
By default, the vector will be rescaled with new minimum and maximum values of 0 and 1.
x <- seq(-3,3,l = 10) x y <- format_scale(x) y
plot(x,y)
You can also change the range of the new scale.
z <- format_scale(x,new_min = 25,new_max = 100)
plot(x,z)
The goal of format_p_value
is to change a p value, by considering a lower bound value where if is the value is smaller than it, let's say 0.001, the p value will be changed to "<0.001"
format_p_value(c(.001,.00000001),lower_bound = 0.001)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.