YEAR: 2021 75 | COPYRIGHT HOLDER: Nick Huntington-Klein 76 |77 | 78 |
vignettes/vtable.Rmd
102 | vtable.RmdThe vtable package serves the purpose of outputting
109 | automatic variable documentation that can be easily viewed while
110 | continuing to work with data.
vtable contains four main functions:
112 | vtable() (or vt()), sumtable()
113 | (or st()), labeltable(), and
114 | dftoHTML()/dftoLaTeX().
Please see the vignettes/articles available on these main functions, 116 | as well as on the vtable helper functions.
117 |This function calculates the number of values in a vector that are NA.
78 |countNA(x)This function just shorthand for sum(is.na(x)), with a shorter name for reference in the vtable or sumtable summ option.
x <- c(1, 1, NA, 2, 3, NA)
100 | countNA(x)
101 | #> [1] 2
102 | R/helpers.R
73 | notNA.comma.RdThis function is shorthand for format(notNA(x), big.mark = ',', scientific = FALSE), a comma-formtted version of notNA, typically for use in sumtable.
notNA.comma(x, ...)A vector.
Other arguments to pass to format besides big.mark and scientific.
x <- c(1:1000000, NA)
98 | notNA.comma(x)
99 | #> [1] "1,000,000"
100 | R/helpers.R
73 | propNA.RdThis function calculates the proportion of values in a vector that are NA.
78 |propNA(x)This function just shorthand for mean(is.na(x)), with a shorter name for reference in the vtable or sumtable summ option.
x <- c(1, 1, NA, 2, 3, NA)
100 | propNA(x)
101 | #> [1] 0.3333333
102 | This function takes a vector and returns the number of unique values in that vector.
78 |nuniq(x)This function is just shorthand for length(unique(x)), with a shorter name for reference in the vtable or sumtable summ option.
x <- c(1, 1, 2, 3, 4, 4, 4)
100 | nuniq(x)
101 | #> [1] 4
102 |
103 | This function calculates 100 percentiles of a vector and returns all of them.
78 |pctile(x)This function just shorthand for quantile(x,1:100/100), with a shorter name for reference in the vtable or sumtable summ option, and which works with sumtable summ.names styling.
This function takes a vector and checks if any information is lost by rounding to a certain number of digits.
78 |is.round(x, digits = 0)Returns TRUE if rounding to digits digits after the decimal can be done without losing information.
is.round(1:5)
104 | #> [1] TRUE
105 |
106 | x <- c(1, 1.2, 1.23)
107 | is.round(x)
108 | #> [1] FALSE
109 | is.round(x,digits=2)
110 | #> [1] TRUE
111 |
75 | All functions76 | 77 | |
78 | |
|---|---|
| 79 | 80 | | 81 |Number of missing values in a vector |
82 |
| 83 | 84 | | 85 |Data Frame to HTML Function |
86 |
| 87 | 88 | | 89 |Data Frame to LaTeX Function |
90 |
| 91 | 92 | | 93 |Function-returning wrapper for format |
94 |
| 95 | 96 | | 97 |Group-Independence Test Function |
98 |
| 99 | 100 | | 101 |Checks if information is lost by rounding |
102 |
| 103 | 104 | | 105 |Label Table Function |
106 |
| 107 | 108 | | 109 |Number of nonmissing values in a vector |
110 |
| 111 | 112 | | 113 |Number of unique values in a vector |
114 |
| 115 | 116 | | 117 |Returns a vector of 100 percentiles |
118 |
| 119 | 120 | | 121 |Proportion or number of missing values in a vector |
122 |
| 123 | 124 | | 125 |Summary Table Function |
126 |
| 127 | 128 | | 129 |Variable Table Function |
130 |
| 131 | 132 | | 133 |Weighted standard deviation |
134 |
This is a basic weighted standard deviation function, mainly for internal use with sumtable.
weighted.sd(x, w, na.rm = TRUE, type = "frequency")A numeric vector.
A vector of weights. Negative weights are not allowed.
Set to TRUE to remove indices with missing values in x or w.
The type of weights to use. The default is 'frequency', which is applied when the weights represent frequencies. Also supports 'precision' which is to be used when the weights represent precision.