GithubHelp home page GithubHelp logo

imbi-heidelberg / descrtab2 Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 7.0 10.14 MB

This package provides functions to create descriptive statistics tables for continuous and categorical variables.

Home Page: https://imbi-heidelberg.github.io/DescrTab2/

R 97.57% CSS 0.01% SAS 2.42%
descriptive-statistics categorical-variables continuous-variable p-values statistics statistical-tests cran r

descrtab2's Introduction

R-CMD-check codecov Github version CRAN Version Downloads CRAN Downloads CRAN last month License

DescrTab2

Publication quality descriptive statistics tables with R

Provides functions to create descriptive statistics tables for continuous and categorical variables. By default, summary statistics such as mean, standard deviation, quantiles, minimum and maximum for continuous variables and relative and absolute frequencies for categorical variables are calculated. DescrTab2 features a sophisticated algorithm to choose appropriate test statistics for your data and provides p-values. On top of this, confidence intervals for group differences of appropriated summary measures are automatically produces for two-group comparison.

Tables generated by DescrTab2 can be integrated in a variety of document formats, including .html, .tex and .docx documents. DescrTab2 also allows printing tables to console and saving table objects for later use.

You can also install the development version of DescrTab2 (recommended) from github by typing:

remotes::install_github("https://github.com/imbi-heidelberg/DescrTab2")

You may also install the stable version of DescrTab2 from cran by typing

install.packages("DescrTab2")

into your R console.

This article may be useful to get aquainted with DescTab2:

https://imbi-heidelberg.github.io/DescrTab2/articles/a_usage_guide.html

You may also check out our documentation page which hosts serveral long-form documentation articles:

https://imbi-heidelberg.github.io/DescrTab2/

descrtab2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

descrtab2's Issues

forcats update

When running the standard iris example from here I obtain:

! `fct_explicit_na()` was deprecated in forcats 1.0.0.
Please use `fct_na_value_to_level()` instead.

Documentation of confidence intervals

In the package website I did not find a description of the computed confidence intervals. If they correspond to the tests, adding them to the test choice tree would probably make sense. I needed it for referencing it in a publication.

In some configurations, unicode characters lead to erros

User observed the following error:

<error/rlang_error>
Obsolete data mask.
x Too late to resolve `Alkohol≥5x/Woche` after the end of `dplyr::mutate()`.
i Did you save an object that uses `Alkohol≥5x/Woche` lazily in a column in the `dplyr::mutate()` expression ?

No idea how to reproduce yet, works on my machine.

documentation of test_options[["indices"]]

Within the excellent usage guidance I couldn't find documentation on how to specify the indices argument when using a paired test. Neither in the test choice tree vignette. I figured out that the variable name of the index variable worked in my case.
Maybe you could add something somewhere?

LaTeX error "Misplaced omit"

I tried to create a descriptive table within an imbiReport2::imbi_report_tex Markdown document with the following chunk:


# Create data frame with 20 variables
df <- data.frame(
  "x1" = 1:10
)

for(i in 2:20){
  df[[paste0("x", i)]] <- 1:10
}

# Print desription table
df %>%
  descr()

The dataset has 20 variables. When compiling the TeX document, it gives the following error:

! Misplaced \omit.
\multispan ->\omit
@multispan
l.296 ...erscript{tt1} Students one-sample t-test}
\ \*

It seems to be caused by a double star (look for \\** in the TeX document) in the longtable environment. When deleting the second star manually in the TeX document, it can be compiled.
Interestingly, this error only occurs for a certain amount of variables/size of table. With 19 and 21 variables, everything works fine. The problem occurs again for 40 variables.

Group labels not printed correctly in PDF

I am trying to add group labels using the group_labels = list() option. However, the group labels are printed erroneously. The first group gets a tag "(N=)" for specifying the number of group members, but without actually specifying the number of members. The second group does not even print this tag at all. Here is a reproducible example:

---
title: "Reprex"
author: "Author"
date: "10 2 2022"
output: pdf_document
---

```{r setup, include=FALSE}
library(DescrTab2)
library(tidyverse)
knitr::opts_chunk$set(echo = TRUE)
options(print_format="tex")
```
## R Markdown
```{r cars}
data(mtcars)
mtcars %>% select(mpg, am) %>% # mutate(QL = factor(MWS)) %>% 
   descr(., group = "am", group_labels = list("0" = "Automatic trans.", "1" = "Manual trans."),
             format_options = list(print_CI = FALSE, print_Total = FALSE, caption="Fuel efficiency depending on transmission type"))
```

This example produces the following output:
Incorrect table
I marked the erroneous and the missing group size tags.

Wilcoxon paired two-sample test does not handle improperly matched data correctly

good_idx <- names(table(id)[table(id) == 2])
if (!all(id %in% good_idx)) {
warning("Removed paired observations with missings.")
}
tibl <- tibble(
var = var,
group = group,
id = id
)
tibl %<>% filter(id %in% good_idx)
level1 <- levels(group)[1]
level2 <- levels(group)[2]
x <-
tibl %>%
filter(group == level1) %>%
arrange(id) %>%
pull(var)
y <-
tibl %>%
filter(group == level2) %>%
arrange(id) %>%
pull(var)

Warning message should read "Data improperly matched". Also need to check table(id, group) < 2 I think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.