├── vignettes ├── .Rhistory ├── .gitignore ├── vtable.Rmd ├── labeltable.Rmd └── dftotable.Rmd ├── LICENSE ├── .gitignore ├── docs ├── reference │ ├── Rplot001.png │ ├── countNA.html │ ├── notNA.comma.html │ ├── propNA.html │ ├── nuniq.html │ ├── pctile.html │ ├── is.round.html │ ├── index.html │ └── weighted.sd.html ├── articles │ ├── vtablehelpers_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-2-1.png │ │ │ └── unnamed-chunk-3-1.png │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.9 │ │ │ └── header-attrs.js │ ├── labeltable_files │ │ ├── kePrint-0.0.1 │ │ │ └── kePrint.js │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.9 │ │ │ └── header-attrs.js │ │ └── lightable-0.0.1 │ │ │ └── lightable.css │ ├── sumtable_files │ │ ├── kePrint-0.0.1 │ │ │ └── kePrint.js │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.9 │ │ │ └── header-attrs.js │ │ └── lightable-0.0.1 │ │ │ └── lightable.css │ ├── vtablefunction_files │ │ ├── kePrint-0.0.1 │ │ │ └── kePrint.js │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.9 │ │ │ └── header-attrs.js │ │ └── lightable-0.0.1 │ │ │ └── lightable.css │ ├── vtable_files │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.9 │ │ │ └── header-attrs.js │ ├── dftotable_files │ │ ├── header-attrs-2.1 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.3 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.8 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.9 │ │ │ └── header-attrs.js │ ├── index.html │ └── vtable.html ├── pkgdown.yml ├── link.svg ├── sitemap.xml ├── bootstrap-toc.css ├── docsearch.js ├── pkgdown.js ├── bootstrap-toc.js ├── LICENSE-text.html ├── 404.html ├── references.html └── authors.html ├── .Rbuildignore ├── NAMESPACE ├── vtable.Rproj ├── man ├── countNA.Rd ├── propNA.Rd ├── nuniq.Rd ├── pctile.Rd ├── is.round.Rd ├── weighted.sd.Rd ├── notNA.Rd ├── dftoLaTeX.Rd ├── dftoHTML.Rd ├── formatfunc.Rd ├── independence.test.Rd └── labeltable.Rd ├── CITATION.cff ├── DESCRIPTION ├── NEWS.md ├── README.Rmd └── R └── independencetest.R /vignettes/.Rhistory: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: Nick Huntington-Klein 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Meta 2 | doc 3 | inst/doc 4 | .Rproj.user 5 | /doc/ 6 | /Meta/ 7 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickCH-K/vtable/HEAD/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^Meta$ 2 | ^doc$ 3 | ^docs$ 4 | ^.*\.Rproj$ 5 | ^\.Rproj\.user$ 6 | ^README.rmd 7 | CITATION.cff 8 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickCH-K/vtable/HEAD/docs/articles/vtablehelpers_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NickCH-K/vtable/HEAD/docs/articles/vtablehelpers_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.2' 2 | pkgdown: 2.1.1 3 | pkgdown_sha: ~ 4 | articles: 5 | dftotable: dftotable.html 6 | labeltable: labeltable.html 7 | sumtable: sumtable.html 8 | vtable: vtable.html 9 | vtablefunction: vtablefunction.html 10 | vtablehelpers: vtablehelpers.html 11 | last_built: 2024-12-19T22:21Z 12 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(countNA) 4 | export(dftoHTML) 5 | export(dftoLaTeX) 6 | export(formatfunc) 7 | export(independence.test) 8 | export(is.round) 9 | export(labeltable) 10 | export(notNA) 11 | export(nuniq) 12 | export(pctile) 13 | export(propNA) 14 | export(st) 15 | export(sumtable) 16 | export(vt) 17 | export(vtable) 18 | export(weighted.sd) 19 | import(kableExtra) 20 | -------------------------------------------------------------------------------- /vtable.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 48797f66-ca3e-487d-8559-fa7432c9e895 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: Sweave 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace,vignette 23 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtable_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/dftotable_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.1/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.3/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.8/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/vtablehelpers_files/header-attrs-2.9/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /man/countNA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{countNA} 4 | \alias{countNA} 5 | \title{Number of missing values in a vector} 6 | \usage{ 7 | countNA(x) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | } 12 | \description{ 13 | This function calculates the number of values in a vector that are NA. 14 | } 15 | \details{ 16 | This function just shorthand for \code{sum(is.na(x))}, with a shorter name for reference in the \code{vtable} or \code{sumtable} \code{summ} option. 17 | } 18 | \examples{ 19 | x <- c(1, 1, NA, 2, 3, NA) 20 | countNA(x) 21 | } 22 | -------------------------------------------------------------------------------- /man/propNA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{propNA} 4 | \alias{propNA} 5 | \title{Proportion or number of missing values in a vector} 6 | \usage{ 7 | propNA(x) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | } 12 | \description{ 13 | This function calculates the proportion of values in a vector that are NA. 14 | } 15 | \details{ 16 | This function just shorthand for \code{mean(is.na(x))}, with a shorter name for reference in the \code{vtable} or \code{sumtable} \code{summ} option. 17 | } 18 | \examples{ 19 | x <- c(1, 1, NA, 2, 3, NA) 20 | propNA(x) 21 | } 22 | -------------------------------------------------------------------------------- /man/nuniq.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{nuniq} 4 | \alias{nuniq} 5 | \title{Number of unique values in a vector} 6 | \usage{ 7 | nuniq(x) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | } 12 | \description{ 13 | This function takes a vector and returns the number of unique values in that vector. 14 | } 15 | \details{ 16 | This function is just shorthand for \code{length(unique(x))}, with a shorter name for reference in the \code{vtable} or \code{sumtable} \code{summ} option. 17 | } 18 | \examples{ 19 | x <- c(1, 1, 2, 3, 4, 4, 4) 20 | nuniq(x) 21 | 22 | } 23 | -------------------------------------------------------------------------------- /man/pctile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{pctile} 4 | \alias{pctile} 5 | \title{Returns a vector of 100 percentiles} 6 | \usage{ 7 | pctile(x) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | } 12 | \description{ 13 | This function calculates 100 percentiles of a vector and returns all of them. 14 | } 15 | \details{ 16 | This function just shorthand for \code{quantile(x,1:100/100)}, with a shorter name for reference in the \code{vtable} or \code{sumtable} \code{summ} option, and which works with \code{sumtable} \code{summ.names} styling. 17 | } 18 | \examples{ 19 | x <- 1:500 20 | pctile(x)[50] 21 | quantile(x,.5) 22 | median(x) 23 | } 24 | -------------------------------------------------------------------------------- /man/is.round.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{is.round} 4 | \alias{is.round} 5 | \title{Checks if information is lost by rounding} 6 | \usage{ 7 | is.round(x, digits = 0) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | 12 | \item{digits}{How many digits to round to.} 13 | } 14 | \description{ 15 | This function takes a vector and checks if any information is lost by rounding to a certain number of digits. 16 | } 17 | \details{ 18 | Returns \code{TRUE} if rounding to \code{digits} digits after the decimal can be done without losing information. 19 | } 20 | \examples{ 21 | is.round(1:5) 22 | 23 | x <- c(1, 1.2, 1.23) 24 | is.round(x) 25 | is.round(x,digits=2) 26 | } 27 | -------------------------------------------------------------------------------- /vignettes/vtable.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "vtable for Data Exploration" 3 | author: "Nick Huntington-Klein" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | 7 | vignette: > 8 | %\VignetteIndexEntry{vtable for Data Exploration} 9 | %\VignetteEngine{knitr::rmarkdown} 10 | %\VignetteEncoding{UTF-8} 11 | --- 12 | 13 | The `vtable` package serves the purpose of outputting automatic variable documentation that can be easily viewed while continuing to work with data. 14 | 15 | `vtable` contains four main functions: `vtable()` (or `vt()`), `sumtable()` (or `st()`), `labeltable()`, and `dftoHTML()`/`dftoLaTeX()`. 16 | 17 | Please see the vignettes/articles available on these main functions, as well as on the vtable helper functions. 18 | 19 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # YAML 1.2 2 | --- 3 | abstract: "This is an R package for the purpose of viewing information about data while working on it. vtable() automatically generates and displays a table of information about the variables in a data set, including name, class, range, labels, and summary statistics." 4 | authors: 5 | - 6 | affiliation: "Seattle University" 7 | family-names: "Huntington-Klein" 8 | given-names: Nick 9 | orcid: "https://orcid.org/https://orcid.org/0000-0002-7352-3991" 10 | cff-version: "1.1.0" 11 | date-released: 2018 12 | license: "MIT + file LICENSE" 13 | message: "If you use this software, please cite it using these metadata." 14 | repository-code: "https://github.com/NickCH-K/vtable" 15 | title: "vtable: A quick and easy variable browser for R." 16 | version: "1.3.3" 17 | ... -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: vtable 2 | Type: Package 3 | Title: Variable Table for Variable Documentation 4 | Version: 1.4.8 5 | Authors@R: c(person(given = "Nick", family = "Huntington-Klein", role = c("aut","cre"), email = "nhuntington-klein@seattleu.edu")) 6 | Description: Automatically generates HTML variable documentation including variable names, labels, classes, value labels (if applicable), value ranges, and summary statistics. See the vignette "vtable" for a package overview. 7 | License: MIT + file LICENSE 8 | Encoding: UTF-8 9 | Depends: 10 | kableExtra 11 | Imports: 12 | utils, 13 | stats, 14 | rstudioapi, 15 | sjlabelled, 16 | haven, 17 | knitr 18 | Suggests: 19 | rmarkdown, 20 | survey 21 | RoxygenNote: 7.3.2 22 | VignetteBuilder: knitr 23 | URL: https://nickch-k.github.io/vtable/ 24 | BugReports: https://github.com/NickCH-K/vtable/issues 25 | -------------------------------------------------------------------------------- /man/weighted.sd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{weighted.sd} 4 | \alias{weighted.sd} 5 | \title{Weighted standard deviation} 6 | \usage{ 7 | weighted.sd(x, w, na.rm = TRUE, type = "frequency") 8 | } 9 | \arguments{ 10 | \item{x}{A numeric vector.} 11 | 12 | \item{w}{A vector of weights. Negative weights are not allowed.} 13 | 14 | \item{na.rm}{Set to \code{TRUE} to remove indices with missing values in \code{x} or \code{w}.} 15 | 16 | \item{type}{The type of weights to use. The default is \code{'frequency'}, which is applied when the weights represent frequencies. Also supports \code{'precision'} which is to be used when the weights represent precision.} 17 | } 18 | \description{ 19 | This is a basic weighted standard deviation function, mainly for internal use with \code{sumtable}. 20 | } 21 | \examples{ 22 | x <- c(1, 1, 2, 3, 4, 4, 4) 23 | w <- c(4, 1, 3, 7, 0, 2, 5) 24 | weighted.sd(x, w) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/notNA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{notNA} 4 | \alias{notNA} 5 | \title{Number of nonmissing values in a vector} 6 | \usage{ 7 | notNA(x, big.mark = NULL, scientific = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A vector.} 11 | 12 | \item{big.mark}{Argument to pass to \code{format()}, if a formatted string is desired.} 13 | 14 | \item{scientific}{Argument to pass to \code{format()} if \code{big.mark} is specified. Defaults to \code{FALSE}, unlike in \code{format()}.} 15 | 16 | \item{...}{Other arguments to pass to \code{format()}. Ignored if \code{big.mark} is not specified.} 17 | } 18 | \description{ 19 | This function calculates the number of values in a vector that are not NA. 20 | } 21 | \details{ 22 | This function just shorthand for \code{sum(!is.na(x))}, with a shorter name for reference in the \code{vtable} or \code{sumtable} \code{summ} option. 23 | 24 | If \code{big.mark} is specified, will return a formatted string instead of a number, where the formatting is based on \code{format(x, big.mark = big.mark, scientific = FALSE, ...)}. 25 | } 26 | \examples{ 27 | x <- c(1, 1, NA, 2, 3, NA) 28 | notNA(x) 29 | notNA(1:10000, big.mark = ',') 30 | } 31 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | /404.html 3 | /articles/dftotable.html 4 | /articles/index.html 5 | /articles/labeltable.html 6 | /articles/sumtable.html 7 | /articles/vtable.html 8 | /articles/vtablefunction.html 9 | /articles/vtablehelpers.html 10 | /authors.html 11 | /index.html 12 | /LICENSE-text.html 13 | /news/index.html 14 | /README.knit.html 15 | /reference/countNA.html 16 | /reference/dftoHTML.html 17 | /reference/dftoLaTeX.html 18 | /reference/format.func.html 19 | /reference/formatfunc.html 20 | /reference/independence.test.html 21 | /reference/index.html 22 | /reference/is.round.html 23 | /reference/labeltable.html 24 | /reference/notNA.comma.html 25 | /reference/notNA.html 26 | /reference/nuniq.html 27 | /reference/pctile.html 28 | /reference/propNA.html 29 | /reference/sumtable.html 30 | /reference/vtable.html 31 | /reference/weighted.sd.html 32 | /references.html 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # vtable 1.3.2 2 | 3 | - Fixes an issue where `format(digits = 0)` was still being used despite no longer being allowed 4 | - Fixes the use of sample weights combined with factor variables that have missing values. 5 | 6 | # vtable 1.3.3 7 | 8 | - Fixes an error that occurs if a character variable with lots of different values is specified in `vars` in `sumtable`. 9 | 10 | # vtable 1.3.4 11 | 12 | - Fixes an issue with `haven_labelled` class variables where value labels weren't recognized in `vtable`. 13 | - Fixes an issue where custom star markers are not recognized in `sumtable`. 14 | - Date variables maintain class before being evaluated for `summ` in `vtable`, and also `lush = TRUE` produces medians and `nuniq()` for dates instead of mean, SD, and `nuniq`. 15 | 16 | # vtable 1.4.1 17 | 18 | - Fixes an issue where group headers didn't show up properly in `sumtable()` with `out = 'kable'` if run outside of **knitr**. 19 | - Adds variable formatting options to `sumtable()`. 20 | - Adds count and frequency columns to `labeltable()`. 21 | - Other minor fixes. 22 | 23 | # vtable 1.4.2 24 | 25 | - `format` option of `sumtable()` changed to `numformat` to avoid namespace issues. 26 | - Added `obs.function` option to `sumtable()` to make it easier to swap out the function used to count observations. 27 | - Made it possible to use a named vector/list to change `numformat` option for only some variables in `sumtable()`, instead of having to specify every single variable. 28 | - Updated vignettes. 29 | - Fixed issue where default `out` option did not work running inside of `knitr` rendering to Word. 30 | - Fixed issue with escaped characters in `kable`s. 31 | - Added `formatfunc()` function to easily customize `numformat` options. 32 | 33 | # vtable 1.4.3 34 | 35 | - Fixed bug introduced by 1.4.2 relating to grouped sumtables when one group has all-missing values of a variable. 36 | 37 | # vtable 1.4.4 38 | 39 | - Improved performance of `formatfunc()` with prefixes and negative values combined. 40 | - Changed factor-level formatting in `vtable()` slightly. 41 | 42 | # vtable 1.4.5 43 | 44 | - Fixes an issue in `sumtable` where characters were not being properly escaped when building to Quarto/RMarkdown and `out` is not specified. 45 | 46 | 47 | # vtable 1.4.6 48 | 49 | - Fixes an issue in `sumtable` with the combination of `tibble`s and `factor.numeric = TRUE`. 50 | 51 | # vtable 1.4.7 52 | 53 | - Adds second approach to weighted SD calculations to allow for weights that represent reliability/precision. 54 | 55 | # vtable 1.4.8 56 | 57 | - Allows `title = NA` and `data.title = NA` to omit titles in `sumtable()` and `vtable()`, which will help in using **vtable** in Quarto documents with native cross-referencing. 58 | -------------------------------------------------------------------------------- /man/dftoLaTeX.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dftotable.R 3 | \name{dftoLaTeX} 4 | \alias{dftoLaTeX} 5 | \title{Data Frame to LaTeX Function} 6 | \usage{ 7 | dftoLaTeX( 8 | data, 9 | file = NA, 10 | fit.page = NA, 11 | frag = TRUE, 12 | title = NA, 13 | note = NA, 14 | note.align = "l", 15 | anchor = NA, 16 | align = NA, 17 | row.names = FALSE, 18 | no.escape = NA 19 | ) 20 | } 21 | \arguments{ 22 | \item{data}{Data set; accepts any format with column names.} 23 | 24 | \item{file}{Saves the completed table to LaTeX with this filepath.} 25 | 26 | \item{fit.page}{uses a LaTeX resizebox to force the table to a certain width. Often \code{'\\textwidth'}.} 27 | 28 | \item{frag}{Set to TRUE to produce only the LaTeX table itself, or FALSE to produce a fully buildable LaTeX. Defaults to TRUE.} 29 | 30 | \item{title}{Character variable with the title of the table. Set to \code{NA} to omit.} 31 | 32 | \item{note}{Table note to go after the last row of the table.} 33 | 34 | \item{note.align}{Set the alignment for the multi-column table note. Usually "l", but if you have a long note you might want to set it with "p{}"} 35 | 36 | \item{anchor}{Character variable to be used to set a label tag for the table.} 37 | 38 | \item{align}{Character variable with standard LaTeX formatting for alignment, for example \code{'lccc'}. You can also use this to force column widths with \code{p} in standard LaTeX style. Defaults to the first column being left-aligned and all others centered. Be sure to escape special characters, in particular backslashes (i.e. \code{p{.25\\\\textwidth}} instead of \code{p{.25\\textwidth}}).} 39 | 40 | \item{row.names}{Flag determining whether or not the row names should be included in the table. Defaults to \code{FALSE}.} 41 | 42 | \item{no.escape}{Vector of column indices for which special characters should not be escaped (perhaps they include markup text of their own).} 43 | } 44 | \description{ 45 | This function takes a data frame or matrix with column names and outputs a lightly-formatted LaTeX table version of that data frame. 46 | } 47 | \details{ 48 | This function is designed to feed LaTeX versions of variable tables to \code{vtable()}, \code{sumtable()}, and \code{labeltable()}. 49 | 50 | Multi-column cells are supported. Wrap the cell's contents in a \code{multicolumn} tag as normal, and then fill in any cells that need to be deleted to make room for the multi-column cell with "DELETECELL". Or use the MULTICOL syntax of \code{dftoHTML}, that works too. 51 | 52 | If the first column and row begins with the text "HEADERROW", then the first row will be put above the column names. 53 | } 54 | \examples{ 55 | df <- data.frame(var1 = 1:4,var2=5:8,var3=c('A','B','C','D'), 56 | var4=as.factor(c('A','B','C','C')),var5=c(TRUE,TRUE,FALSE,FALSE)) 57 | dftoLaTeX(df, align = 'ccccc') 58 | 59 | } 60 | -------------------------------------------------------------------------------- /man/dftoHTML.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dftotable.R 3 | \name{dftoHTML} 4 | \alias{dftoHTML} 5 | \title{Data Frame to HTML Function} 6 | \usage{ 7 | dftoHTML( 8 | data, 9 | out = NA, 10 | file = NA, 11 | note = NA, 12 | note.align = "l", 13 | anchor = NA, 14 | col.width = NA, 15 | col.align = NA, 16 | row.names = FALSE, 17 | no.escape = NA 18 | ) 19 | } 20 | \arguments{ 21 | \item{data}{Data set; accepts any format with column names.} 22 | 23 | \item{out}{Determines where the completed table is sent. Set to \code{"browser"} to open HTML file in browser using \code{browseURL()}, \code{"viewer"} to open in RStudio viewer using \code{viewer()}, if available, or \code{"htmlreturn"} to return the HTML code. Defaults to Defaults to \code{"viewer"} if RStudio is running and \code{"browser"} if it isn't.} 24 | 25 | \item{file}{Saves the completed variable table file to HTML with this filepath. May be combined with any value of \code{out}.} 26 | 27 | \item{note}{Table note to go after the last row of the table.} 28 | 29 | \item{note.align}{Alignment of table note, l, r, or c.} 30 | 31 | \item{anchor}{Character variable to be used to set an \code{} tag for the table.} 32 | 33 | \item{col.width}{Vector of page-width percentages, on 0-100 scale, overriding default column widths in HTML table. Must have a number of elements equal to the number of columns in the resulting table.} 34 | 35 | \item{col.align}{Vector of 'left', 'right', 'center', etc. to be used with the HTML table text-align attribute in each column. If you want to get tricky, you can add a \code{";"} afterwards and keep putting in whatever CSS attributes you want. They will be applied to the whole column.} 36 | 37 | \item{row.names}{Flag determining whether or not the row names should be included in the table. Defaults to \code{FALSE}.} 38 | 39 | \item{no.escape}{Vector of column indices for which special characters should not be escaped (perhaps they include markup text of their own).} 40 | } 41 | \description{ 42 | This function takes a data frame or matrix with column names and outputs an HTML table version of that data frame. 43 | } 44 | \details{ 45 | This function is designed to feed HTML versions of variable tables to \code{vtable()}, \code{sumtable()}, and \code{labeltable()}. 46 | 47 | Multi-column cells are supported. Set the cell's contents to \code{"content_MULTICOL_c_5"} where "content" is the content of the cell, "c" is the cell's alignment (l, c, r), and 5 is the number of columns to span. Then fill in the cells that need to be deleted to make room with "DELETECELL". 48 | 49 | If the first column and row begins with the text "HEADERROW", then the first row will be put above the column names. 50 | } 51 | \examples{ 52 | 53 | if(interactive()) { 54 | df <- data.frame(var1 = 1:4,var2=5:8,var3=c('A','B','C','D'), 55 | var4=as.factor(c('A','B','C','C')),var5=c(TRUE,TRUE,FALSE,FALSE)) 56 | dftoHTML(df,out="browser") 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /man/formatfunc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \name{formatfunc} 4 | \alias{formatfunc} 5 | \title{Function-returning wrapper for format} 6 | \usage{ 7 | formatfunc( 8 | percent = FALSE, 9 | prefix = "", 10 | suffix = "", 11 | scale = 1, 12 | digits = NULL, 13 | nsmall = 0L, 14 | big.mark = "", 15 | trim = TRUE, 16 | scientific = FALSE, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{percent}{Whether to apply percentage formatting. Set to \code{TRUE} if 1 = 100\%. Or, optionally, set to any other number that represents 100\%. So \code{percent = TRUE} or \code{percent = 1} will interpret \code{.9} as \code{90\%}, or \code{percent = 100} will format \code{90} as \code{90\%}.} 22 | 23 | \item{prefix}{A prefix to apply to the formatted number. For example, \code{prefix = '$'} would format \code{4} as \code{$4}.} 24 | 25 | \item{suffix}{A suffix to apply to the formatted number. If specified alongside \code{percent}, the suffix comes after the \%.} 26 | 27 | \item{scale}{A scalar value to be multiplied by all numbers prior to formatting. \code{scale = 1/1000}, for example, would convert the units into thousands. This is applied before \code{digits}.} 28 | 29 | \item{digits}{Number of significant digits.} 30 | 31 | \item{nsmall}{The minimum number of digits to the right of the decimal point.} 32 | 33 | \item{big.mark}{A character to mark thousands places, for example producing "1,000" instead of "1000".} 34 | 35 | \item{trim}{Whether numbers should be trimmed to their own size, rather than being right-justified to a common width. Unlike the actual \code{format()}, this defaults to \code{TRUE}. Note that in most vtable applications, the formatting function is applied one value at a time, rather than to a vector, so \code{trim = FALSE} may not work as intended.} 36 | 37 | \item{scientific}{Whether numbers should be encoded in scientific format. Unlike the actual \code{format()}, this defaults to \code{FALSE}.} 38 | 39 | \item{...}{Arguments to be passed to \code{format()}. See \code{help(format)}. All other parameters listed above except for \code{percent}, \code{prefix}, or \code{suffix} are also just part of \code{format}, but may be of particular interest, or have been included to show how defaults have changed.} 40 | } 41 | \description{ 42 | This function takes a set of options for the \code{format()} function and returns a function that itself calls \code{format()} with those settings. 43 | } 44 | \details{ 45 | The only differences are: 46 | 47 | 1. \code{scientific} is set to \code{FALSE} by default, and \code{trim} is set to \code{TRUE} 48 | 2. Passing a \code{NA} value produces \code{''} instead of \code{'NA'}. 49 | 3. In addition to standard \code{format()} options, it also accepts a \code{percent} option to apply percentage formatting, and \code{prefix} and \code{suffix} options to apply prefixes or suffixes to formatted numbers. 50 | 4. Has an attribute \code{'big.mark'} storing the \code{'big.mark'} option chosen. 51 | 52 | This is in the spirit of the \code{label_} functions in the scales package, except that it uses \code{format()}'s focus on significant digits instead of fixed decimal places, which is good for numbers that range across multiple orders of magnitude, common in \code{sumtable()} and \code{vtable()}. 53 | } 54 | \examples{ 55 | x <- c(1, 1000, .000235, 1298.255, NA) 56 | my.formatting.func = formatfunc(digits = 3, prefix = '$') 57 | my.formatting.func(x) 58 | 59 | } 60 | -------------------------------------------------------------------------------- /man/independence.test.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/independencetest.R 3 | \name{independence.test} 4 | \alias{independence.test} 5 | \title{Group-Independence Test Function} 6 | \usage{ 7 | independence.test( 8 | x, 9 | y, 10 | w = NA, 11 | factor.test = NA, 12 | numeric.test = NA, 13 | star.cutoffs = c(0.01, 0.05, 0.1), 14 | star.markers = c("***", "**", "*"), 15 | digits = 3, 16 | fixed.digits = FALSE, 17 | format = "{name}={stat}{stars}", 18 | opts = list() 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{A categorical variable.} 23 | 24 | \item{y}{A variable to test for independence with \code{x}. This can be a factor or numeric variable. If you want a numeric variable treated as categorical, convert to a factor first.} 25 | 26 | \item{w}{A vector of weights to pass to the appropriate test.} 27 | 28 | \item{factor.test}{Used when \code{y} is a factor, a function that takes \code{x} and \code{y} as its first arguments and returns a list with three arguments: (1) The name of the test for printing, (2) the test statistic, and (3) the p-value. Defaults to a Chi-squared test if there are no weights, or a design-based F statistic (Rao & Scott Aadjustment, see \code{survey::svychisq}) with weights, which requires that the \code{survey} package be installed. WARNING: the Chi-squared test's assumptions fail with small sample sizes. This function will be attempted for all non-numeric \code{y}.} 29 | 30 | \item{numeric.test}{Used when \code{y} is numeric, a function that takes \code{x} and \code{y} as its first arguments and returns a list with three arguments: (1) The name of the test for printing, (2) the test statistic, and (3) the p-value. Defaults to a group differences F test. If you only have two groups and would prefer an absolute t-statistic to an F-statistic, pass \code{vtable:::groupt.it}.} 31 | 32 | \item{star.cutoffs}{A numeric vector indicating the p-value cutoffs to use for reporting significance stars. Defaults to \code{c(.01,.05,.1)}. If you don't want stars, remove them from the \code{format} argument.} 33 | 34 | \item{star.markers}{A character vector indicating the symbols to use to indicate significance cutoffs associated with \code{star.cuoffs}. Defaults to \code{c('***','**','*')}. If you don't want stars, remove them from the \code{format} argument.} 35 | 36 | \item{digits}{Number of digits after the decimal to round the test statistic and p-value to.} 37 | 38 | \item{fixed.digits}{\code{FALSE} will cut off trailing \code{0}s when rounding. \code{TRUE} retains them. Defaults to \code{FALSE}.} 39 | 40 | \item{format}{The way in which the four elements returned by (or calculated after) the test - \code{{name}}, \code{{stat}}, \code{{pval}}, and \code{{stars}} - will be arranged in the string output. Note that the default \code{'{name}={stat}{stars}'} does not contain the p-value, and also does not contain superscript for the stars since it doesn't know what markup language you're aiming for. For LaTeX you may prefer \code{'{name}$={stat}^{{stars}}$'}, and for HTML \code{'{name}={stat}{stars}'}.} 41 | 42 | \item{opts}{The options listed above, entered in named-list format.} 43 | } 44 | \description{ 45 | This function takes in two variables of equal length, the first of which is a categorical variable, and performs a test of independence between them. It returns a character string with the results of that test for putting in a table. 46 | } 47 | \details{ 48 | In an attempt (and perhaps an encouragement) to use this function in weird ways, and because it's not really expected to be used directly, input is not sanitized. Have fun! 49 | } 50 | \examples{ 51 | 52 | data(mtcars) 53 | independence.test(mtcars$cyl,mtcars$mpg) 54 | 55 | } 56 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $("div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /man/labeltable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/labeltable.R 3 | \name{labeltable} 4 | \alias{labeltable} 5 | \title{Label Table Function} 6 | \usage{ 7 | labeltable( 8 | var, 9 | ..., 10 | out = NA, 11 | count = FALSE, 12 | percent = FALSE, 13 | file = NA, 14 | desc = NA, 15 | note = NA, 16 | note.align = NA, 17 | anchor = NA 18 | ) 19 | } 20 | \arguments{ 21 | \item{var}{A vector. Label table will show, for each of the values of this variable, its label (if labels can be found with \code{sjlabelled::get_labels()}), or the values in the \code{...} variables.} 22 | 23 | \item{...}{As described above. If specified, will show the values of these variables, instead of the labels of var, even if labels can be found.} 24 | 25 | \item{out}{Determines where the completed table is sent. Set to \code{"browser"} to open HTML file in browser using \code{browseURL()}, \code{"viewer"} to open in RStudio viewer using \code{viewer()}, if available. Use \code{"htmlreturn"} to return the HTML code to R, \code{"return"} to return the completed variable table to R in data frame form, or \code{"kable"} to return it in \code{knitr::kable()} form. Combine \code{out = "csv"} with \code{file} to write to CSV (dropping most formatting). Additional options include \code{"latex"} for a LaTeX table or \code{"latexpage"} for a full buildable LaTeX page. Defaults to \code{"viewer"} if RStudio is running, \code{"browser"} if it isn't, or a \code{"kable"} passed through \code{kableExtra::kable_styling()} defaults if it's an RMarkdown document being built with \code{knitr}.} 26 | 27 | \item{count}{Set to \code{TRUE} to also report the number of observations for each value of \code{var} in the data.} 28 | 29 | \item{percent}{Set to \code{TRUE} to also report the percentage of non-missing observation for each value of \code{var} in the data.} 30 | 31 | \item{file}{Saves the completed variable table file to HTML with this filepath. May be combined with any value of \code{out}, although note that \code{out = "return"} and \code{out = "kable"} will still save the standard labeltable HTML file as with \code{out = "viewer"} or \code{out = "browser"}..} 32 | 33 | \item{desc}{Description of variable (or labeling system) to be included with the table.} 34 | 35 | \item{note}{Table note to go after the last row of the table.} 36 | 37 | \item{note.align}{Set the alignment for the multi-column table note. Usually "l", but if you have a long note in LaTeX you might want to set it with "p{}"} 38 | 39 | \item{anchor}{Character variable to be used to set an anchor link in HTML tables, or a label tag in LaTeX.} 40 | } 41 | \description{ 42 | This function output a descriptive table listing, for each value of a given variable, either the label of that value, or all values of another variable associated with that value. The table is output either to the console or as an HTML file that can be viewed continuously while working with data. 43 | } 44 | \details{ 45 | Outputting the label table as a help file will make it easy to search through value labels, or to see the correspondence between the values of one variable and the values of another. 46 | 47 | Labels that are not in the data will also be reported in the table. 48 | } 49 | \examples{ 50 | \dontshow{ 51 | #These tests use the out='htmlreturn' option 52 | #so that the same process of generating HTML is followed 53 | #but a browser window is not opened during testing. 54 | #This process is identical to regular operation except that 55 | #HTML is written to the R output rather than a browser. 56 | 57 | #Input a single labelled variable to see a table relating values to labels. 58 | #Values not present in the data will be included in the table but moved to the end. 59 | library(sjlabelled) 60 | data(efc) 61 | labeltable(efc$e15relat,out='htmlreturn') 62 | 63 | #Include multiple variables to see, for each value of the first variable, 64 | #each value of the others present in the data. 65 | data(efc) 66 | labeltable(efc$e15relat,efc$e16sex,efc$e42dep,out='htmlreturn') 67 | 68 | #Commonly, the multi-variable version might be used to recover the original 69 | #values of encoded variables 70 | data(USJudgeRatings) 71 | USJudgeRatings$Judge <- row.names(USJudgeRatings) 72 | USJudgeRatings$JudgeID <- as.numeric(as.factor(USJudgeRatings$Judge)) 73 | labeltable(USJudgeRatings$JudgeID,USJudgeRatings$Judge,out='htmlreturn') 74 | } 75 | if(interactive()){ 76 | #Input a single labelled variable to see a table relating values to labels. 77 | #Values not present in the data will be included in the table but moved to the end. 78 | library(sjlabelled) 79 | data(efc) 80 | labeltable(efc$e15relat) 81 | 82 | #Include multiple variables to see, for each value of the first variable, 83 | #each value of the others present in the data. 84 | data(efc) 85 | labeltable(efc$e15relat,efc$e16sex,efc$e42dep) 86 | 87 | #Commonly, the multi-variable version might be used to recover the original 88 | #values of encoded variables 89 | data(USJudgeRatings) 90 | USJudgeRatings$Judge <- row.names(USJudgeRatings) 91 | USJudgeRatings$JudgeID <- as.numeric(as.factor(USJudgeRatings$Judge)) 92 | labeltable(USJudgeRatings$JudgeID,USJudgeRatings$Judge) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | always_allow_html: true 4 | --- 5 | 6 | 7 | 8 | ```{r, include = FALSE} 9 | library(vtable) 10 | knitr::opts_chunk$set( 11 | collapse = TRUE, 12 | warning = FALSE, 13 | message = FALSE, 14 | comment = "#>", 15 | fig.path = "man/figures/README-", 16 | out.width = "100%" 17 | ) 18 | ``` 19 | # vtable 20 | 21 | 22 | 23 | [![](http://cranlogs.r-pkg.org/badges/grand-total/vtable?color=orange)](https://cran.r-project.org/package=vtable) [![](http://cranlogs.r-pkg.org/badges/last-month/vtable?color=green)](https://cran.r-project.org/package=vtable) [![](https://www.r-pkg.org/badges/version/vtable?color=blue)](https://cran.r-project.org/package=vtable) [![CRAN 24 | checks](https://cranchecks.info/badges/summary/vtable)](https://cran.r-project.org/web/checks/check_results_vtable.html) [![CRAN status](https://www.r-pkg.org/badges/version/vtable)](https://CRAN.R-project.org/package=vtable) 25 | 26 | 27 | 28 | The **vtable** package is designed to help you quickly and efficiently look at and document your data. 29 | 30 | There are three main functions in **vtable**: 31 | 32 | 1. `vtable`, or `vt` for short, shows you information about the variables in your data set, including variable labels, in a way that is easy to use "find in page" to search through. It was designed to be similar to Stata's "Variables" panel. 33 | 2. `sumtable` or `st` for short, provides a table of summary statistics. It is very similar in spirit to the summary statistics function of `stargazer::stargazer()` except that it accepts `tibble`s, handles factor variables, and makes by-group statistics and group tests easy. 34 | 3. `labeltable` provides a table of value labels, either for variables labelled with **sjlabelled** or **haven** or similar, or for when you want to see how the values of one column line up with the values of another. 35 | 36 | All three of these functions are built with the intent of being *fast*. Not so much fast to *run*, but fast to *use*. The defaults are intended to be good defaults, and the output by default prints to the Viewer tab (in RStudio) or the browser (outside RStudio) so you can see it immediately, and continue to look at it as you work on your data. 37 | 38 | You could almost certainly build your own highly-customized version of `vtable`, But why do that when you can just do `vt(df)` and see the information you need to see? And there are eight million packages that make summary statistics tables to your exact specifications if you tweak them. But there's a good chance that `st(df)` does what you want. If you want something real out there, that's when you can break out the big guns. 39 | 40 | All three main **vtable** functions can produce HTML, LaTeX, `data.frame`, CSV, or `knitr::kable()` output. 41 | 42 | ## Installation 43 | 44 | You can install vtable from CRAN. Note that the documentation on this site refers to the development version, and so may not work perfectly for the CRAN version. But the two will usually be the same.: 45 | 46 | ```r 47 | install.packages("vtable") 48 | ``` 49 | 50 | ### Development version 51 | 52 | The development version can be installed from [GitHub](https://github.com/): 53 | 54 | ``` r 55 | # install.packages("remotes") 56 | remotes::install_github("NickCH-K/vtable") 57 | ``` 58 | ## vtable Example 59 | 60 | I'll just do a brief example here, using the `iris` we all know and love. Output will be to `kable` since this is an RMarkdown document. 61 | 62 | ```{r} 63 | data(iris) 64 | 65 | # Basic vtable 66 | vt(iris) 67 | ``` 68 | 69 | There are plenty of options if we want to go nuts, but let's keep it simple and just ask for a little more with `lush` 70 | 71 | ```{r} 72 | vt(iris, lush = TRUE) 73 | ``` 74 | 75 | ## sumtable Example 76 | 77 | Let's stick with `iris`! 78 | 79 | ```{r} 80 | # Basic summary stats 81 | st(iris) 82 | ``` 83 | 84 | Note that `sumtable` allows for much more customization than `vtable` since there's a heightened chance you want it for a paper or something. But I'll leave that to the more detailed documentation. For now just note it does by-group stats, either in "`group.long`" format (multiple `sumtable`s stacked on top of each other), or by default, in columns, with an option to add a group test. 85 | 86 | Grouped `sumtables` look a little nicer in formats that suport multi-column cells like HTML and LaTeX. 87 | 88 | **These tables include multi-column cells, which are not supported in the `kable` output, but are supported by `vtable`'s `dftoHTML` and `dftoLaTeX` functions. They look nicer in the HTML or LaTeX output.** 89 | 90 | ```{r} 91 | st(iris, 92 | group = 'Species', 93 | group.test = TRUE) 94 | ``` 95 | 96 | ## labeltable Example 97 | 98 | For this we'll need labeled values. 99 | 100 | ```{r} 101 | data(efc, package = 'sjlabelled') 102 | 103 | # Now shoot - how was gender coded? 104 | labeltable(efc$e16sex) 105 | ``` 106 | 107 | `labeltable` can also be used to see, for values of one variable, what values are present of other variables. This is intended for use if one variable is a recode, simplification, or lost-labels version of another, but hey, go nuts. 108 | 109 | ```{r} 110 | labeltable(efc$e15relat,efc$e16sex,efc$e42dep) 111 | ``` 112 | -------------------------------------------------------------------------------- /vignettes/labeltable.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "labeltable: Label Table" 3 | author: "Nick Huntington-Klein" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | 7 | vignette: > 8 | %\VignetteIndexEntry{labeltable: Label Table} 9 | %\VignetteEngine{knitr::rmarkdown} 10 | %\VignetteEncoding{UTF-8} 11 | --- 12 | 13 | The `vtable` package serves the purpose of outputting automatic variable documentation that can be easily viewed while continuing to work with data. 14 | 15 | `vtable` contains four main functions: `vtable()` (or `vt()`), `sumtable()` (or `st()`), `labeltable()`, and `dftoHTML()`/`dftoLaTeX()`. This vignette focuses on `labeltable()`. 16 | 17 | `labeltable()` is designed to take a single variable and show the values it is associated with. This can also be used to generate data documentation if desired, or can just be an easy way to look at label values, or learn more about the data you're working with. 18 | 19 | If that variable has value labels from the `sjlabelled` or `haven` packages, it will show how the values in the data correspond to the value labels. 20 | 21 | Alternately, you can include other variables as well, and `labeltable()` will show, for each value of the variable you're interested in, the values that those other variables take. This can be handy, for example, if you used some variables to create a numeric ID and want to remember what original values correspond to each ID. It can also act as sort of a cross-tabulation. 22 | 23 | ----- 24 | 25 | 26 | # The `labeltable()` function 27 | 28 | `vtable()` syntax follows the following outline: 29 | 30 | ```{r, eval=FALSE} 31 | labeltable(var, 32 | ..., 33 | out=NA, 34 | count=FALSE, 35 | percent=FALSE, 36 | file=NA, 37 | desc=NA, 38 | note=NA, 39 | note.align=NA, 40 | anchor=NA) 41 | ``` 42 | 43 | `labeltable()` is a function that shows the values that correspond to `var`. This could be value label values, or it could be the values found in the data for the `...` variables. 44 | 45 | ```{r} 46 | #Include a single labelled variable to show how the values of that variable correspond to its value labels. 47 | library(vtable) 48 | library(sjlabelled) 49 | data(efc) 50 | labeltable(efc$e15relat) 51 | ``` 52 | 53 | ```{r} 54 | #Include more than one variable to show, for each value of the first, what values of the others are present in the data. 55 | data(mtcars) 56 | labeltable(mtcars$cyl,mtcars$carb,mtcars$am) 57 | ``` 58 | 59 | ## `out` 60 | 61 | The `out` option determines what will be done with the resulting label table file. There are several options for `out`: 62 | 63 | | Option | Result | 64 | |------------| -----------------------------------------| 65 | | browser | Loads output in web browser. | 66 | | viewer | Loads output in Viewer pane (RStudio only). | 67 | | htmlreturn | Returns HTML code for output file. | 68 | | return | Returns output table in data.frame format. | 69 | | csv | Returns output table in data.frame format and, with a `file` option, saves that to CSV. | 70 | | kable | Returns a `knitr::kable()` | 71 | | latex | Returns a LaTeX table. | 72 | | latexpage | Returns an independently-buildable LaTeX document. | 73 | 74 | By default, `vtable` will select 'viewer' if running in RStudio, and 'browser' otherwise. If it's being built in an RMarkdown document with `knitr`, it will default to 'kable'. 75 | 76 | ## `count` and `percent` 77 | 78 | These options allow `labeltable()` to act as a sort of `table()`, where it will also include the counts and/or percentage of the variable that takes each value. 79 | 80 | ```{r} 81 | library(vtable) 82 | data(LifeCycleSavings) 83 | labeltable(efc$e15relat, count = TRUE, percent = TRUE) 84 | ``` 85 | 86 | ## `file` 87 | 88 | The `file` argument will write the variable documentation file to an HTML file and save it. Will automatically append 'html' filetype if the filename does not include a period. 89 | 90 | ```{r, eval=FALSE} 91 | library(vtable) 92 | 93 | data(LifeCycleSavings) 94 | labeltable(efc$e15relat,file='lifecycle_variabledocumentation') 95 | ``` 96 | 97 | ## `desc`, `note`, and `anchor`. 98 | 99 | `desc` will include a description of the data set (or whatever you like) in the file, which may be useful for documentation purposes. 100 | 101 | `note` will add a table note in the last row. 102 | 103 | `anchor` will add an anchor ID (` 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | License • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 73 | 74 |
    YEAR: 2021
     75 | COPYRIGHT HOLDER: Nick Huntington-Klein
     76 | 
    77 | 78 |
    79 | 80 | 83 | 84 |
    85 | 86 | 87 | 88 |
    91 | 92 |
    93 |

    Site built with pkgdown 2.1.1.

    94 |
    95 | 96 |
    97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • vtable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 |
    24 |
    88 | 89 | 90 | 91 | 92 |
    93 |
    94 | 97 | 98 | Content not found. Please use links in the navbar. 99 | 100 |
    101 | 102 | 106 | 107 |
    108 | 109 | 110 | 111 |
    115 | 116 |
    117 |

    118 |

    Site built with pkgdown 2.1.1.

    119 |
    120 | 121 |
    122 |
    123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/references.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | • vtable 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
    62 |
    63 | 132 | 133 | 134 | 135 |
    136 | 137 |
    138 |
    139 | 142 | 143 | 144 | 145 |
    146 | 147 | 152 | 153 |
    154 | 155 | 156 | 157 |
    158 | 161 | 162 |
    163 |

    Site built with pkgdown 1.6.1.

    164 |
    165 | 166 |
    167 |
    168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 73 | 74 | 91 |
    92 |
    93 | 94 | 95 |
    98 | 99 |
    100 |

    Site built with pkgdown 2.1.1.

    101 |
    102 | 103 |
    104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /docs/articles/sumtable_files/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /docs/articles/labeltable_files/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /docs/articles/vtablefunction_files/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 |
    71 | 74 | 75 | 76 |
    • 77 |

      Nick Huntington-Klein. Author, maintainer. 78 |

      79 |
    • 80 |
    81 |
    82 |
    83 |

    Citation

    84 | Source: DESCRIPTION 85 |
    86 |
    87 | 88 | 89 |

    Huntington-Klein N (2024). 90 | vtable: Variable Table for Variable Documentation. 91 | R package version 1.4.8, https://nickch-k.github.io/vtable/. 92 |

    93 |
    @Manual{,
     94 |   title = {vtable: Variable Table for Variable Documentation},
     95 |   author = {Nick Huntington-Klein},
     96 |   year = {2024},
     97 |   note = {R package version 1.4.8},
     98 |   url = {https://nickch-k.github.io/vtable/},
     99 | }
    100 | 101 |
    102 | 103 |
    104 | 105 | 106 | 107 |
    110 | 111 |
    112 |

    Site built with pkgdown 2.1.1.

    113 |
    114 | 115 |
    116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /R/independencetest.R: -------------------------------------------------------------------------------- 1 | #' Group-Independence Test Function 2 | #' 3 | #' This function takes in two variables of equal length, the first of which is a categorical variable, and performs a test of independence between them. It returns a character string with the results of that test for putting in a table. 4 | #' 5 | #' In an attempt (and perhaps an encouragement) to use this function in weird ways, and because it's not really expected to be used directly, input is not sanitized. Have fun! 6 | #' 7 | #' @param x A categorical variable. 8 | #' @param y A variable to test for independence with \code{x}. This can be a factor or numeric variable. If you want a numeric variable treated as categorical, convert to a factor first. 9 | #' @param w A vector of weights to pass to the appropriate test. 10 | #' @param factor.test Used when \code{y} is a factor, a function that takes \code{x} and \code{y} as its first arguments and returns a list with three arguments: (1) The name of the test for printing, (2) the test statistic, and (3) the p-value. Defaults to a Chi-squared test if there are no weights, or a design-based F statistic (Rao & Scott Aadjustment, see \code{survey::svychisq}) with weights, which requires that the \code{survey} package be installed. WARNING: the Chi-squared test's assumptions fail with small sample sizes. This function will be attempted for all non-numeric \code{y}. 11 | #' @param numeric.test Used when \code{y} is numeric, a function that takes \code{x} and \code{y} as its first arguments and returns a list with three arguments: (1) The name of the test for printing, (2) the test statistic, and (3) the p-value. Defaults to a group differences F test. If you only have two groups and would prefer an absolute t-statistic to an F-statistic, pass \code{vtable:::groupt.it}. 12 | #' @param star.cutoffs A numeric vector indicating the p-value cutoffs to use for reporting significance stars. Defaults to \code{c(.01,.05,.1)}. If you don't want stars, remove them from the \code{format} argument. 13 | #' @param star.markers A character vector indicating the symbols to use to indicate significance cutoffs associated with \code{star.cuoffs}. Defaults to \code{c('***','**','*')}. If you don't want stars, remove them from the \code{format} argument. 14 | #' @param digits Number of digits after the decimal to round the test statistic and p-value to. 15 | #' @param fixed.digits \code{FALSE} will cut off trailing \code{0}s when rounding. \code{TRUE} retains them. Defaults to \code{FALSE}. 16 | #' @param format The way in which the four elements returned by (or calculated after) the test - \code{{name}}, \code{{stat}}, \code{{pval}}, and \code{{stars}} - will be arranged in the string output. Note that the default \code{'{name}={stat}{stars}'} does not contain the p-value, and also does not contain superscript for the stars since it doesn't know what markup language you're aiming for. For LaTeX you may prefer \code{'{name}$={stat}^{{stars}}$'}, and for HTML \code{'{name}={stat}{stars}'}. 17 | #' @param opts The options listed above, entered in named-list format. 18 | #' @examples 19 | #' 20 | #' data(mtcars) 21 | #' independence.test(mtcars$cyl,mtcars$mpg) 22 | #' 23 | #' @export independence.test 24 | independence.test <- function(x,y,w=NA, 25 | factor.test = NA, 26 | numeric.test = NA, 27 | star.cutoffs = c(.01,.05,.1), 28 | star.markers = c('***','**','*'), 29 | digits = 3, 30 | fixed.digits = FALSE, 31 | format = '{name}={stat}{stars}', 32 | opts = list()) { 33 | #Bring in opts 34 | list2env(opts,envir=environment()) 35 | #Are we using factor.test or numeric.test 36 | cla <- is.numeric(y) 37 | 38 | # Backwards consistency 39 | if (length(w) == 1) { 40 | if (is.na(w)) { 41 | w <- NULL 42 | } 43 | } 44 | 45 | #Fill in defaults 46 | if (identical(factor.test,NA)) { 47 | factor.test <- chisq.it 48 | } 49 | if (identical(numeric.test,NA)) { 50 | numeric.test <- groupf.it 51 | } 52 | 53 | if (cla) { 54 | result <- numeric.test(x,y,w) 55 | } else { 56 | result <- factor.test(x,y,w) 57 | } 58 | 59 | #Get stars 60 | #Order smallest to biggest 61 | star.markers <- star.markers[order(star.cutoffs)] 62 | star.cutoffs <- star.cutoffs[order(star.cutoffs)] 63 | #Find the first value that qualifies 64 | underneath <- result[[3]] < star.cutoffs 65 | stars <- star.markers[underneath][1] 66 | stars <- ifelse(is.na(stars),'',stars) 67 | 68 | #Rounding 69 | #First, check if we're going to get a 0, so we can set that separate 70 | is.zero <- result[[3]] < 10^(-digits) 71 | if (fixed.digits) { 72 | result[[2]] <- format(result[[2]],digits=digits,nsmall=digits) 73 | result[[3]] <- format(result[[3]],digits=digits,nsmall=digits) 74 | } else { 75 | result[[2]] <- round(result[[2]],digits=digits) 76 | result[[3]] <- round(result[[3]],digits=digits) 77 | } 78 | if (is.zero) { 79 | result[[3]] <- paste0('<',10^(-digits)) 80 | } 81 | 82 | #And format the result 83 | printout <- format 84 | #Fill in our four things 85 | printout <- gsub('\\{name\\}',result[[1]],printout) 86 | printout <- gsub('\\{stat\\}',result[[2]],printout) 87 | printout <- gsub('\\{pval\\}',result[[3]],printout) 88 | printout <- gsub('\\{stars\\}',stars,printout) 89 | 90 | return(printout) 91 | } 92 | 93 | 94 | groupt.it <- function(x, y, w = NULL) { 95 | if (length(unique(x)) > 2) { 96 | stop('groupt.it cannot be used with more than two groups.') 97 | } 98 | return(groupf.it(x=x, y=y, w=w, t = TRUE)) 99 | } 100 | 101 | # Internal chi-square and group-F tests that return things in independence.test format 102 | chisq.it <- function(x,y,w=NULL) { 103 | if (is.null(w)) { 104 | suppressWarnings(result <- stats::chisq.test(x,y)) 105 | 106 | return(list( 107 | 'X2', 108 | unname(result$statistic), 109 | result$p.value 110 | )) 111 | } else { 112 | # Create survey design 113 | d <- data.frame(x = x, y = y, w = w) 114 | errmess <- try(sdes <- survey::svydesign(~1, data = d, weights = ~w)) 115 | 116 | if (grepl('Error in loadNamespace',errmess[1])) { 117 | stop('Using weights with group.test = TRUE and factor variables requires the survey package. install.packages("survey")') 118 | } 119 | 120 | ftest <- survey::svychisq(~x+y, sdes) 121 | return(list( 122 | 'F', 123 | unname(ftest$statistic), 124 | unname(ftest$p.value) 125 | )) 126 | } 127 | } 128 | groupf.it <- function(x,y,w=NULL, t = FALSE) { 129 | result <- stats::anova(stats::lm(y~factor(x),weights = w)) 130 | statname <- 'F' 131 | stat <- result$`F value`[1] 132 | 133 | if (t) { 134 | statname <- 't' 135 | stat <- sqrt(stat) 136 | } 137 | 138 | return(list( 139 | statname, 140 | stat, 141 | result$`Pr(>F)`[1] 142 | )) 143 | } 144 | -------------------------------------------------------------------------------- /docs/articles/vtable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | vtable for Data Exploration • vtable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 |
    24 |
    88 | 89 | 90 | 91 | 92 |
    93 |
    94 | 105 | 106 | 107 | 108 |

    The vtable package serves the purpose of outputting 109 | automatic variable documentation that can be easily viewed while 110 | continuing to work with data.

    111 |

    vtable contains four main functions: 112 | vtable() (or vt()), sumtable() 113 | (or st()), labeltable(), and 114 | dftoHTML()/dftoLaTeX().

    115 |

    Please see the vignettes/articles available on these main functions, 116 | as well as on the vtable helper functions.

    117 |
    118 | 119 | 122 | 123 |
    124 | 125 | 126 | 127 |
    131 | 132 |
    133 |

    134 |

    Site built with pkgdown 2.1.1.

    135 |
    136 | 137 |
    138 |
    139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/reference/countNA.html: -------------------------------------------------------------------------------- 1 | 2 | Number of missing values in a vector — countNA • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function calculates the number of values in a vector that are NA.

    78 |
    79 | 80 |
    81 |
    countNA(x)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A vector.

    90 | 91 |
    92 |
    93 |

    Details

    94 |

    This function just shorthand for sum(is.na(x)), with a shorter name for reference in the vtable or sumtable summ option.

    95 |
    96 | 97 |
    98 |

    Examples

    99 |
    x <- c(1, 1, NA, 2, 3, NA)
    100 | countNA(x)
    101 | #> [1] 2
    102 | 
    103 |
    104 |
    105 | 108 |
    109 | 110 | 111 |
    114 | 115 |
    116 |

    Site built with pkgdown 2.1.1.

    117 |
    118 | 119 |
    120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/reference/notNA.comma.html: -------------------------------------------------------------------------------- 1 | 2 | Number of nonmissing values in a vector, in comma formatting — notNA.comma • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function is shorthand for format(notNA(x), big.mark = ',', scientific = FALSE), a comma-formtted version of notNA, typically for use in sumtable.

    78 |
    79 | 80 |
    81 |
    notNA.comma(x, ...)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 |
    x
    87 |

    A vector.

    88 | 89 | 90 |
    ...
    91 |

    Other arguments to pass to format besides big.mark and scientific.

    92 | 93 |
    94 | 95 |
    96 |

    Examples

    97 |
    x <- c(1:1000000, NA)
     98 | notNA.comma(x)
     99 | #> [1] "1,000,000"
    100 | 
    101 |
    102 |
    103 | 106 |
    107 | 108 | 109 |
    112 | 113 |
    114 |

    Site built with pkgdown 2.0.7.

    115 |
    116 | 117 |
    118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/reference/propNA.html: -------------------------------------------------------------------------------- 1 | 2 | Proportion or number of missing values in a vector — propNA • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function calculates the proportion of values in a vector that are NA.

    78 |
    79 | 80 |
    81 |
    propNA(x)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A vector.

    90 | 91 |
    92 |
    93 |

    Details

    94 |

    This function just shorthand for mean(is.na(x)), with a shorter name for reference in the vtable or sumtable summ option.

    95 |
    96 | 97 |
    98 |

    Examples

    99 |
    x <- c(1, 1, NA, 2, 3, NA)
    100 | propNA(x)
    101 | #> [1] 0.3333333
    102 | 
    103 |
    104 |
    105 | 108 |
    109 | 110 | 111 |
    114 | 115 |
    116 |

    Site built with pkgdown 2.1.1.

    117 |
    118 | 119 |
    120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/reference/nuniq.html: -------------------------------------------------------------------------------- 1 | 2 | Number of unique values in a vector — nuniq • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function takes a vector and returns the number of unique values in that vector.

    78 |
    79 | 80 |
    81 |
    nuniq(x)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A vector.

    90 | 91 |
    92 |
    93 |

    Details

    94 |

    This function is just shorthand for length(unique(x)), with a shorter name for reference in the vtable or sumtable summ option.

    95 |
    96 | 97 |
    98 |

    Examples

    99 |
    x <- c(1, 1, 2, 3, 4, 4, 4)
    100 | nuniq(x)
    101 | #> [1] 4
    102 | 
    103 | 
    104 |
    105 |
    106 | 109 |
    110 | 111 | 112 |
    115 | 116 |
    117 |

    Site built with pkgdown 2.1.1.

    118 |
    119 | 120 |
    121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /vignettes/dftotable.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "dftoHTML and dftoLaTeX: Data Frame Formatting" 3 | author: "Nick Huntington-Klein" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | 7 | vignette: > 8 | %\VignetteIndexEntry{dftoHTML and dftoLaTeX: Data Frame Formatting} 9 | %\VignetteEngine{knitr::rmarkdown} 10 | %\VignetteEncoding{UTF-8} 11 | --- 12 | 13 | The `vtable` package serves the purpose of outputting automatic variable documentation that can be easily viewed while continuing to work with data. 14 | 15 | `vtable` contains four main functions: `vtable()` (or `vt()`), `sumtable()` (or `st()`), `labeltable()`, and `dftoHTML()`/`dftoLaTeX()`. This vignette focuses on `dftoHTML()`/`dftoLaTeX()`. 16 | 17 | `dftoHTML()` and `dftoLaTeX` are helper functions used by `vtable()`, `sumtable()`, and `labeltable()`. They takes any data frame or matrix with column names and outputs HTML or LaTeX table code for that data. 18 | 19 | Note that none of the vignettes in this example are set to run because `dftoHTML` and `dftoLaTeX` output is intended to go to places other than Markdown (although both can certainly be used with 'asis' chunks to produce results in Markdown). 20 | 21 | ----- 22 | 23 | # The `dftoHTML()` function 24 | 25 | `dftoHTML()` syntax follows the following outline: 26 | 27 | ```{r, eval = FALSE} 28 | dftoHTML(data, 29 | out=NA, 30 | file=NA, 31 | note=NA, 32 | anchor=NA, 33 | col.width=NA, 34 | col.align=NA, 35 | row.names=FALSE, 36 | no.escape=NA) 37 | ``` 38 | 39 | `dftoHTML()` largely exists to serve `vtable()`, `sumtable()`, and `labeltable()`. What it does is takes a data set `data` and returns an HTML table with the contents of that data. 40 | 41 | Outside of its use with other `vtable` functions, `dftoHTML()` can also be used to keep a view of the data file open while working on the data, avoiding repeated calls to `head()` or similar, or switching back and forth between code tabs and data view tabs. 42 | 43 | ------ 44 | 45 | ## `data` 46 | 47 | `dftoHTML()` will accept any data set with a `colnames()` attribute. 48 | 49 | ```{r, eval = FALSE} 50 | library(vtable) 51 | 52 | data(LifeCycleSavings) 53 | dftoHTML(LifeCycleSavings) 54 | ``` 55 | 56 | ## out 57 | 58 | The `out` option determines what will be done with the resulting variable documentation file. There are several options for `out`: 59 | 60 | | Option | Result | 61 | |------------| -----------------------------------------| 62 | | browser | Loads HTML version of `data` in web browser. | 63 | | viewer | Loads HTML version of `data` in Viewer pane (RStudio only). | 64 | | htmlreturn | Returns HTML code for `data`. | 65 | 66 | By default, `vtable` will select 'viewer' if running in RStudio, and 'browser' otherwise. 67 | 68 | ```{r, eval=FALSE} 69 | library(vtable) 70 | 71 | data(LifeCycleSavings) 72 | dftoHTML(LifeCycleSavings) 73 | dftoHTML(LifeCycleSavings,out='browser') 74 | dftoHTML(LifeCycleSavings,out='viewer') 75 | htmlcode <- dftoHTML(LifeCycleSavings,out='htmlreturn') 76 | ``` 77 | 78 | ## `file` 79 | 80 | The `file` argument will write the HTML version of `data` to an HTML file and save it. Will automatically append 'html' filetype if the filename does not include a period. 81 | 82 | ```{r, eval=FALSE} 83 | data(LifeCycleSavings) 84 | dftoHTML(LifeCycleSavings,file='lifecycledata_htmlversion.html') 85 | ``` 86 | 87 | ## `note` 88 | 89 | `note` will add a table note in the last row. 90 | 91 | ```{r, eval = FALSE} 92 | dftoHTML(LifeCycleSavings,note='Data from Belsley, Kuh, and Welsch 1980'). 93 | ``` 94 | 95 | ## `anchor` 96 | 97 | `anchor` will add an anchor ID (` 2 | Returns a vector of 100 percentiles — pctile • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function calculates 100 percentiles of a vector and returns all of them.

    78 |
    79 | 80 |
    81 |
    pctile(x)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A vector.

    90 | 91 |
    92 |
    93 |

    Details

    94 |

    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.

    95 |
    96 | 97 |
    98 |

    Examples

    99 |
    x <- 1:500
    100 | pctile(x)[50]
    101 | #>   50% 
    102 | #> 250.5 
    103 | quantile(x,.5)
    104 | #>   50% 
    105 | #> 250.5 
    106 | median(x)
    107 | #> [1] 250.5
    108 | 
    109 |
    110 |
    111 | 114 |
    115 | 116 | 117 |
    120 | 121 |
    122 |

    Site built with pkgdown 2.1.1.

    123 |
    124 | 125 |
    126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/reference/is.round.html: -------------------------------------------------------------------------------- 1 | 2 | Checks if information is lost by rounding — is.round • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This function takes a vector and checks if any information is lost by rounding to a certain number of digits.

    78 |
    79 | 80 |
    81 |
    is.round(x, digits = 0)
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A vector.

    90 | 91 | 92 |
    digits
    93 |

    How many digits to round to.

    94 | 95 |
    96 |
    97 |

    Details

    98 |

    Returns TRUE if rounding to digits digits after the decimal can be done without losing information.

    99 |
    100 | 101 |
    102 |

    Examples

    103 |
    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 | 
    112 |
    113 |
    114 | 117 |
    118 | 119 | 120 |
    123 | 124 |
    125 |

    Site built with pkgdown 2.1.1.

    126 |
    127 | 128 |
    129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | Package index • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 73 | 74 | 78 | 81 | 82 | 85 | 86 | 89 | 90 | 93 | 94 | 97 | 98 | 101 | 102 | 105 | 106 | 109 | 110 | 113 | 114 | 117 | 118 | 121 | 122 | 125 | 126 | 129 | 130 | 133 | 134 |
    75 |

    All functions

    76 |

    77 |
    79 |

    countNA()

    80 |

    Number of missing values in a vector

    83 |

    dftoHTML()

    84 |

    Data Frame to HTML Function

    87 |

    dftoLaTeX()

    88 |

    Data Frame to LaTeX Function

    91 |

    formatfunc()

    92 |

    Function-returning wrapper for format

    95 |

    independence.test()

    96 |

    Group-Independence Test Function

    99 |

    is.round()

    100 |

    Checks if information is lost by rounding

    103 |

    labeltable()

    104 |

    Label Table Function

    107 |

    notNA()

    108 |

    Number of nonmissing values in a vector

    111 |

    nuniq()

    112 |

    Number of unique values in a vector

    115 |

    pctile()

    116 |

    Returns a vector of 100 percentiles

    119 |

    propNA()

    120 |

    Proportion or number of missing values in a vector

    123 |

    sumtable() st()

    124 |

    Summary Table Function

    127 |

    vtable() vt()

    128 |

    Variable Table Function

    131 |

    weighted.sd()

    132 |

    Weighted standard deviation

    135 | 136 | 139 |
    140 | 141 | 142 |
    145 | 146 |
    147 |

    Site built with pkgdown 2.1.1.

    148 |
    149 | 150 |
    151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /docs/reference/weighted.sd.html: -------------------------------------------------------------------------------- 1 | 2 | Weighted standard deviation — weighted.sd • vtable 6 | 7 | 8 |
    9 |
    65 | 66 | 67 | 68 |
    69 |
    70 | 75 | 76 |
    77 |

    This is a basic weighted standard deviation function, mainly for internal use with sumtable.

    78 |
    79 | 80 |
    81 |
    weighted.sd(x, w, na.rm = TRUE, type = "frequency")
    82 |
    83 | 84 |
    85 |

    Arguments

    86 | 87 | 88 |
    x
    89 |

    A numeric vector.

    90 | 91 | 92 |
    w
    93 |

    A vector of weights. Negative weights are not allowed.

    94 | 95 | 96 |
    na.rm
    97 |

    Set to TRUE to remove indices with missing values in x or w.

    98 | 99 | 100 |
    type
    101 |

    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.

    102 | 103 |
    104 | 105 |
    106 |

    Examples

    107 |
    x <- c(1, 1, 2, 3, 4, 4, 4)
    108 | w <- c(4, 1, 3, 7, 0, 2, 5)
    109 | weighted.sd(x, w)
    110 | #> [1] 1.243828
    111 | 
    112 | 
    113 |
    114 |
    115 | 118 |
    119 | 120 | 121 |
    130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | --------------------------------------------------------------------------------