Giter Club home page Giter Club logo

Comments (4)

ddsjoberg avatar ddsjoberg commented on June 19, 2024

Thanks for the post @rawand-hanna . I think you'll need to add some concrete examples of what you're requesting. I am not sure I follow 100%

from gtsummary.

rawand-hanna avatar rawand-hanna commented on June 19, 2024

Hey @ddsjoberg
Thanks for the response

Here is an example

library(tidyverse)
library(gtsummary)

df <- tibble(language = c('Arabic French', 'French Spanish', 'Spanish Arabic', 'Arabic', 'French'),
education = c('Primary', 'Primary', 'Secondary', 'Secondary', 'Primary'))

df %>% tbl_summary(by = education) %>%
add_overall() %>%
add_p()

Here is the result
image

The issue is that the cross table is not displaying each language on a separate row, instead, it displays each combination of languages on each row.

Is there a way to tell gtsummary that the type of a variable is categorical with 'select multiple' type?

from gtsummary.

ddsjoberg avatar ddsjoberg commented on June 19, 2024

Perhaps this will be helpful: https://mskcc-epi-bio.github.io/bstfun/reference/add_variable_grouping.html

As I mentioned in the stackoverflow post you recently made, gtsummary will only tabulate what is in the data frame.

from gtsummary.

rawand-hanna avatar rawand-hanna commented on June 19, 2024

Thanks @ddsjoberg
You are the best

Just a quick note, while using the add_variable_grouping() function, the p-value is still calculated per each of the categorical variables with the cross-tab variable.

Untitled

I used the same sample code as here

Added age_group variable to the code

`set.seed(11234)

data.frame(
race_asian = sample(c(TRUE, FALSE), 20, replace = TRUE),
race_black = sample(c(TRUE, FALSE), 20, replace = TRUE),
race_white = sample(c(TRUE, FALSE), 20, replace = TRUE),
age = rnorm(20, mean = 50, sd = 10)
) %>%
mutate(age_group = cut(age, breaks = 3)) %>%
gtsummary::tbl_summary(by = age_group,
label = list(race_asian = "Asian",
race_black = "Black",
race_white = "White",
age = "Age")
) %>%
add_variable_grouping(
"Race (check all that apply)" = c("race_asian", "race_black", "race_white")
) %>%
add_p()`

from gtsummary.

Related Issues (20)

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.