### Install DescTools Package Source: https://github.com/andrisignorell/desctools/blob/master/README.md Instructions for installing the DescTools package from CRAN or the development version from GitHub. ```R install.packages("DescTools") if (!require("remotes")) install.packages("remotes") remotes::install_github("AndriSignorell/DescTools") ``` -------------------------------- ### Install RDCOMClient for MS-Office Integration Source: https://github.com/andrisignorell/desctools/blob/master/README.md Commands to install the RDCOMClient package required for MS-Office features, which is restricted to Windows systems. ```R install.packages("RDCOMClient", repos="http://www.omegahat.net/R") url <- "http://www.omegahat.net/R/bin/windows/contrib/4.2/RDCOMClient_0.96-1.zip" install.packages(url, repos = NULL, type = "binary") ``` -------------------------------- ### jQuery Animation Setup Utilities (st, ut, lt) Source: https://github.com/andrisignorell/desctools/blob/master/README.html Helper functions for setting up animations. 'st' creates properties for animating box model dimensions and opacity. 'ut' finds the appropriate tween for a given property. 'lt' is the main animation function that orchestrates the entire animation process. ```javascript function st(e,t){var n,r=0,i={height:e}; for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e; return t&&(i.opacity=i.width=e),i} function ut(e,t,n){for(var r,i=(lt.tweeners[t]||[]).concat(lt.tweeners["*"]),o=0,a=i.length;oF)"], lbl = "ANOVA"), cat = list(fun = function(x, g) chisq.test(table(x, g))$p.val, lbl = "Chi-Square test"), dich = list(fun = function(x, g) fisher.test(table(x, g))$p.val, lbl = "Fisher exact test") ) ) # Suppress tests TOne(x = d.pizza[, c("temperature", "driver")], grp = d.pizza$area, TEST = NA) ``` -------------------------------- ### CSS for Navigation Elements Source: https://github.com/andrisignorell/desctools/blob/master/README.html Provides base styles for navigation lists ('nav' class) and specifically for tabbed navigation ('nav-tabs' class). It includes styling for list items, links, active states, and hover effects, ensuring proper display and interaction. ```css .nav{padding-left:0;margin-bottom:0;list-style:none}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:focus,.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#777}.nav>li.disabled>a:focus,.nav>li.disabled>a:hover{color:#777;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:focus,.nav .open>a:hover{background-color:#eee;border-color:#337ab7}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.42857143;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:focus,.nav-tabs>li.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bo ``` -------------------------------- ### Bootstrap Alert Component Initialization Source: https://github.com/andrisignorell/desctools/blob/master/README.html Initializes the alert plugin and handles the closing functionality for elements with the data-dismiss attribute. It manages CSS transitions and DOM removal upon alert dismissal. ```javascript +function(a){ "use strict"; function b(b){ return this.each(function(){ var c=a(this),e=c.data("bs.alert"); e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c) }) } var c='[data-dismiss="alert"]',d=function(b){ a(b).on("click",c,this.close) }; d.VERSION="3.3.5"; d.prototype.close=function(b){ /* ... implementation ... */ }; var e=a.fn.alert; a.fn.alert=b; }(jQuery); ``` -------------------------------- ### Info Button Styling (CSS) Source: https://github.com/andrisignorell/desctools/blob/master/README.html Styles for informational buttons, using a cyan color scheme. Covers hover, focus, active, and disabled states for consistent UI feedback. ```css .btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info.focus,.btn-info:focus{color:#fff;background-color:#31b0d5;border-color:#1b6d85}.btn-info:hover{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active.focus,.btn-info.active:focus,.btn-info.active:hover,.btn-info:active.focus,.btn-info:active:focus,.btn-info:active:hover,.open>.dropdown-toggle.btn-info.focus,.open>.dropdown-toggle.btn-info:focus,.open>.dropdown-toggle.btn-info:hover{color:#fff;background-color:#269abc;border-color:#1b6d85}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff} ``` -------------------------------- ### Calculate Binomial Proportion Confidence Intervals with BinomCI() Source: https://context7.com/andrisignorell/desctools/llms.txt Computes confidence intervals for binomial proportions using methods like Wilson, Clopper-Pearson, and Agresti-Coull. Supports vectorized inputs and sample size estimation via BinomCIn(). ```R library(DescTools) # Basic usage with Wilson method BinomCI(x = 37, n = 43) # Compare multiple methods BinomCI(x = 37, n = 43, method = c("wilson", "clopper-pearson", "agresti-coull", "jeffreys")) # Vectorized inputs BinomCI(x = c(42, 35, 23, 22), n = 43, method = "wilson") # Sample size calculation BinomCIn(p = 0.5, width = 0.1, conf.level = 0.95, method = "wilson") ``` -------------------------------- ### jQuery Library Initialization Source: https://github.com/andrisignorell/desctools/blob/master/README.html The core jQuery v3.6.0 library implementation. It provides a robust API for DOM manipulation, event handling, and AJAX requests. ```javascript !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){...}); ``` -------------------------------- ### Function to Build Tabsets from HTML Sections Source: https://github.com/andrisignorell/desctools/blob/master/README.html A JavaScript function 'buildTabsets' that converts HTML elements with the class 'section tabset' into Bootstrap-style tab interfaces. It supports 'fade' and 'pills' options, determines tab levels based on heading hierarchy, and dynamically creates navigation lists and content panes. It also integrates with the sticky tabs functionality if the 'tabset-sticky' class is present. ```javascript window.buildTabsets = function(tocID) { function buildTabset(tabset) { var fade = tabset.hasClass("tabset-fade"); var pills = tabset.hasClass("tabset-pills"); var navClass = pills ? "nav-pills" : "nav-tabs"; var match = tabset.attr('class').match(/level(\d) /); if (match === null) return; var tabsetLevel = Number(match[1]); var tabLevel = tabsetLevel + 1; var tabs = tabset.find("div.section.level" + tabLevel); if (!tabs.length) return; var tabList = $(''); $(tabs[0]).before(tabList); var tabContent = $(''); $(tabs[0]).before(tabContent); var activeTab = 0; tabs.each(function(i) { var tab = $(tabs[i]); var id = tab.attr('id'); if (tab.hasClass('active')) activeTab = i; $("div#" + tocID + " li a[href='#" + id + "']").parent().remove(); id = id.replace(/[[.\/?&!#<>]/g, '').replace(/\s/g, '_'); tab.attr('id', id); var heading = tab.find('h' + tabLevel + ':first'); var headingText = heading.html(); heading.remove(); var a = $('' + headingText + ''); a.attr('href', '#' + id); a.attr('aria-controls', id); var li = $('
'); li.append(a); tabList.append(li); tab.attr('role', 'tabpanel'); tab.addClass('tab-pane'); tab.addClass('tabbed-pane'); if (fade) tab.addClass('fade'); tab.detach().appendTo(tabContent); }); $(tabList.children('li')[activeTab]).addClass('active'); var active = $(tabContent.children('div.section')[activeTab]); active.addClass('active'); if (fade) active.addClass('in'); if (tabset.hasClass("tabset-sticky")) tabset.rmarkdownStickyTabs(); } var tabsets = $("div.section.tabset"); tabsets.each(function(i) { buildTabset($(tabsets[i])); }); }; ``` -------------------------------- ### Calculate Binomial Ratio Confidence Intervals Source: https://github.com/andrisignorell/desctools/blob/master/man/BinomRatioCI.rd Demonstrates how to use the BinomRatioCI function to calculate confidence intervals for the ratio of two binomial proportions using different statistical methods like Katz and Koopman. ```R # From Koopman (1984) BinomRatioCI(x1 = 36, n1 = 40, x2 = 16, n2 = 80, method = "katz") BinomRatioCI(x1 = 36, n1 = 40, x2 = 16, n2 = 80, method = "koop") ``` -------------------------------- ### Modal Scrollbar and Layout Management Source: https://github.com/andrisignorell/desctools/blob/master/README.html Utility methods to calculate scrollbar width and adjust body padding to prevent layout shifts when modals are opened or closed. ```javascript c.prototype.measureScrollbar=function(){var a=document.createElement("div");a.className="modal-scrollbar-measure",this.$body.append(a);var b=a.offsetWidth-a.clientWidth;return this.$body[0].removeChild(a),b};c.prototype.setScrollbar=function(){var a=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing&&this.$body.css("padding-right",a+this.scrollbarWidth)}; ``` -------------------------------- ### BinomCI - Confidence Intervals for Binomial Proportions Source: https://context7.com/andrisignorell/desctools/llms.txt Computes confidence intervals for binomial proportions using multiple methods including Wilson (default), Clopper-Pearson (exact), Agresti-Coull, Jeffreys, Wald, and others. Supports vectorized input, one-sided intervals, and argument recycling. ```APIDOC ## BinomCI - Confidence Intervals for Binomial Proportions ### Description Computes confidence intervals for binomial proportions using various statistical methods. Supports vectorized input, one-sided intervals, and argument recycling. ### Method R Function ### Endpoint N/A (R Package Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```R library(DescTools) # Basic usage with Wilson method (default, recommended) BinomCI(x = 37, n = 43) # Compare multiple methods BinomCI(x = 37, n = 43, method = c("wilson", "clopper-pearson", "agresti-coull", "jeffreys")) # Vectorized: multiple x values with same n BinomCI(x = c(42, 35, 23, 22), n = 43, method = "wilson") # Different x and n values BinomCI(x = c(42, 35, 23, 22), n = c(50, 60, 70, 80), method = "jeffreys") # One-sided confidence interval (left = greater alternative) BinomCI(x = 37, n = 43, sides = "left", conf.level = 0.95) # 99% confidence interval BinomCI(x = 37, n = 43, conf.level = 0.99) # Sample size calculation for desired CI width BinomCIn(p = 0.5, width = 0.1, conf.level = 0.95, method = "wilson") ``` ### Response #### Success Response (200) Returns a matrix or vector containing the estimated proportion and the lower and upper bounds of the confidence interval. #### Response Example ``` # For BinomCI(x = 37, n = 43): # est lci uci # 0.8604651 0.7263302 0.9367082 # For BinomCIn(): # [1] 385 (required sample size) ``` ``` -------------------------------- ### Responsive Visibility Utility Classes Source: https://github.com/andrisignorell/desctools/blob/master/README.html CSS utility classes to show or hide elements based on specific screen size breakpoints. These classes use !important to ensure consistent behavior across different device widths. ```css @media (max-width:767px) { .visible-xs { display: block !important; } } @media (min-width:768px) and (max-width:991px) { .visible-sm { display: block !important; } } @media (min-width:992px) and (max-width:1199px) { .visible-md { display: block !important; } } @media (min-width:1200px) { .visible-lg { display: block !important; } } ``` -------------------------------- ### Bootstrap Tab Component Management (JavaScript) Source: https://github.com/andrisignorell/desctools/blob/master/README.html This snippet outlines the JavaScript implementation for managing Bootstrap's Tab component. It enables users to switch between different content panes using clickable tabs. The code handles showing tabs, activating tab elements, and managing transitions, including fade effects and ARIA attributes for accessibility. ```javascript var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){ ``` -------------------------------- ### Clearfix and Layout Utility Classes Source: https://github.com/andrisignorell/desctools/blob/master/README.html Standard utility classes for clearing floats and managing element display properties. These are essential for maintaining layout integrity in grid-based systems. ```css .clearfix:after, .clearfix:before { display: table; content: " "; } .clearfix:after { clear: both; } .center-block { display: block; margin-right: auto; margin-left: auto; } .pull-right { float: right !important; } .pull-left { float: left !important; } .hide { display: none !important; } ``` -------------------------------- ### Bootstrap Scrollspy Component Initialization (JavaScript) Source: https://github.com/andrisignorell/desctools/blob/master/README.html This code demonstrates the initialization and functionality of the Bootstrap Scrollspy component. It tracks scroll position to automatically update active navigation links based on the visible section of the page. It includes methods for refreshing offsets, processing scroll events, activating targets, and clearing active states. ```javascript a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery) ``` -------------------------------- ### Bootstrap Affix Component (jQuery) Source: https://github.com/andrisignorell/desctools/blob/master/README.html Implements the Bootstrap affix component, which pins elements to the viewport when scrolling past a specified offset. It handles affixing to the top or bottom based on scroll position and target element dimensions. Requires jQuery. ```javascript function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.5",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('\\[data-spy="affix"\\]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery) ``` -------------------------------- ### Flexible Number Formatting (R) Source: https://context7.com/andrisignorell/desctools/llms.txt Provides flexible number formatting with support for significant digits, fixed decimals, percentages, p-values with significance stars, and thousands separators. Also supports date formatting. ```R library(DescTools) # Fixed decimal places Format(c(1234.5678, 0.00123, 99999.1), digits = 2) # "1234.57" "0.00" "99999.10" # With thousands separator Format(c(1234567, 9999), digits = 0, big.mark = "'") # "1'234'567" "9'999" # Percentage format Format(c(0.123, 0.456, 0.789), fmt = "%", digits = 1) # "12.3%" "45.6%" "78.9%" # P-value format with significance stars Format(c(0.001, 0.05, 0.1, 0.5), fmt = "*") # "0.001 ***" "0.050 *" "0.100 ." "0.500" ``` -------------------------------- ### Pagination Styles (CSS) Source: https://github.com/andrisignorell/desctools/blob/master/README.html Defines the styling for pagination controls, allowing users to navigate through multiple pages of content. Includes styles for list items, links, hover states, active pages, and disabled states. Also includes styles for large and small pagination variants. ```css .pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{z-index:3;color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:2;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px;line-height:1.3333333}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px;line-height:1.5}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px} ``` -------------------------------- ### Describe Data with Desc() Source: https://context7.com/andrisignorell/desctools/llms.txt The Desc() function provides automated summaries for various data types including numeric, factor, and bivariate relationships. It supports formula interfaces and integrated plotting for quick data exploration. ```R library(DescTools) # Describe a numeric variable Desc(d.pizza$temperature, main = "Temperature Analysis") # Describe a factor variable Desc(d.pizza$driver, main = "Driver Distribution") # Describe relationship between two variables Desc(temperature ~ driver, data = d.pizza) # Describe a data frame Desc(d.pizza[, c("temperature", "delivery_min", "driver")]) # Describe with plotting Desc(d.pizza$temperature, plotit = TRUE) ``` -------------------------------- ### Utility Functions for Data Manipulation Source: https://context7.com/andrisignorell/desctools/llms.txt Provides convenience functions for finding extreme values, range operators, calculating means, Gini coefficients, and data cleaning tasks like LOCF. ```R library(DescTools) Large(1:10, k = 3) Small(1:10, k = 3) x <- 1:10 x %[]% c(3, 7) x %()% c(3, 7) x %[)% c(3, 7) Mode(c(1, 2, 2, 3, 3, 3, 4)) Gmean(c(1, 2, 4, 8)) Hmean(c(1, 2, 4, 8)) Gini(c(10, 20, 30, 40, 100)) Lc(c(10, 20, 30, 40, 100)) Recode(d.pizza$driver, "Carpenter" = "Team A", "Miller" = "Team A", "Taylor" = "Team B") x <- c(1, NA, NA, 4, NA, 6) LOCF(x) Closest(c(1, 5, 10, 20), 8) ``` -------------------------------- ### Sizzle.js Document and Element Handling Utilities Source: https://github.com/andrisignorell/desctools/blob/master/README.html This snippet includes utility functions for Sizzle.js related to document handling, element type checking, and support detection. It defines functions to set the document context, check if an element is an HTML element, and determine browser support for various features. ```javascript function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||"!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+ ``` -------------------------------- ### Calculate Median Confidence Intervals with MedianCI() Source: https://context7.com/andrisignorell/desctools/llms.txt Computes confidence intervals for the median using exact binomial methods or bootstrap approaches. Useful for non-parametric analysis of skewed data. ```R library(DescTools) x <- d.pizza$delivery_min[1:50] # Exact CI for median MedianCI(x, na.rm = TRUE) # Bootstrap CI for median MedianCI(x, method = "boot", type = "perc", na.rm = TRUE) ```