R version 4.5.0 beta (2025-03-31 r88079 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ##### > ## Tests for summary tables > require("papeR") Loading required package: papeR Loading required package: car Loading required package: carData Loading required package: xtable Registered S3 method overwritten by 'papeR': method from Anova.lme car Attaching package: 'papeR' The following object is masked from 'package:utils': toLatex > > if (require("nlme")) { + ## Use dataset Orthodont + data(Orthodont, package = "nlme") + + ## Get summary for continuous variables + (tab1 <- summarize(Orthodont, type = "numeric")) + get_option(tab1, "sep") + summary(tab1) + ## check handling of digits and sep + (tab1a <- summarize(Orthodont, type = "numeric", digits = 3, sep = TRUE)) + get_option(tab1a, "sep") + + ## Change statistics to display + summarize(Orthodont, quantiles = FALSE, type = "numeric") + summarize(Orthodont, quantiles = FALSE, count = FALSE, type = "numeric") + (tmp <- summarize(Orthodont, mean_sd = FALSE, type = "numeric")) + + ## Get summary for categorical variables + (tab2 <- summarize(Orthodont, type = "fac")) + get_option(tab2, "sep") + summary(tab2) + ## check handling of digits and sep + (tab2a <- summarize(Orthodont, type = "fac", digits = 4, sep = FALSE)) + get_option(tab2a, "sep") + + ## use fraction instead of percentage + summarize(Orthodont, percent = FALSE, type = "fac") + + ## try using the tables with Markdown + if (require("knitr")) { + kable(tab1) + kable(tab2) + } + + if (require("xtable")) { + ans <- xtable(tab1) + print(ans) + ## grouped + xtable(summarize(Orthodont, group = "Sex")) + print(xtable(tab2)) + } + } Loading required package: nlme Factors are dropped from the summary Factors are dropped from the summary Factors are dropped from the summary Factors are dropped from the summary Factors are dropped from the summary Non-factors are dropped from the summary Non-factors are dropped from the summary Non-factors are dropped from the summary Loading required package: knitr NOTE: Output requires \usepackage{booktabs} in your preamble. \begin{center} % latex table generated in R 4.5.0 by xtable 1.8-4 package % Tue Apr 1 17:06:26 2025 \begin{tabular}{lrrrrrrrrrr} \toprule & N & & Mean & SD & & Min & Q1 & Median & Q3 & Max \\ \cmidrule{2-2} \cmidrule{4-5} \cmidrule{7-11} distance & 108 & & 24.02 & 2.93 & & 16.50 & 22.00 & 23.75 & 26.00 & 31.50 \\ age & 108 & & 11.00 & 2.25 & & 8.00 & 9.00 & 11.00 & 13.00 & 14.00 \\ \bottomrule \end{tabular} \end{center} Factors are dropped from the summary NOTE: Output requires \usepackage{booktabs} in your preamble. \begin{center} % latex table generated in R 4.5.0 by xtable 1.8-4 package % Tue Apr 1 17:06:26 2025 \begin{tabular}{llrrr} \toprule & Level & & N & \% \\ \cmidrule{2-2} \cmidrule{4-5} Subject & M16 & & 4 & 3.7 \\ & M05 & & 4 & 3.7 \\ & M02 & & 4 & 3.7 \\ & M11 & & 4 & 3.7 \\ & M07 & & 4 & 3.7 \\ & M08 & & 4 & 3.7 \\ & M03 & & 4 & 3.7 \\ & M12 & & 4 & 3.7 \\ & M13 & & 4 & 3.7 \\ & M14 & & 4 & 3.7 \\ & M09 & & 4 & 3.7 \\ & M15 & & 4 & 3.7 \\ & M06 & & 4 & 3.7 \\ & M04 & & 4 & 3.7 \\ & M01 & & 4 & 3.7 \\ & M10 & & 4 & 3.7 \\ & F10 & & 4 & 3.7 \\ & F09 & & 4 & 3.7 \\ & F06 & & 4 & 3.7 \\ & F01 & & 4 & 3.7 \\ & F05 & & 4 & 3.7 \\ & F07 & & 4 & 3.7 \\ & F02 & & 4 & 3.7 \\ & F08 & & 4 & 3.7 \\ & F03 & & 4 & 3.7 \\ & F04 & & 4 & 3.7 \\ & F11 & & 4 & 3.7 \\ \cmidrule{2-2} \cmidrule{4-5} Sex & Male & & 64 & 59.3 \\ & Female & & 44 & 40.7 \\ \bottomrule \end{tabular} \end{center} > > > proc.time() user system elapsed 0.57 0.14 0.68