Git Product home page Git Product logo

Comments (3)

ewenharrison avatar ewenharrison commented on July 29, 2024

Thanks for these Graeme.
It would help if you could make some toy data that demonstrates the problem and also include the error.

from finalfit.

graemeleehickey avatar graemeleehickey commented on July 29, 2024

The following example works in finalfit:

library(finalfit)
library(dplyr)
data(colon_s)

explanatory <- c("age", "age.factor", "sex", "obstruct.factor")
dependent <- "perfor.factor"
colon_s %>%
  summary_factorlist(dependent, explanatory, p = TRUE)

However, from time to time you may have a binary variable (e.g. in a subgroup analysis with a low prevalence covariate) where all values are zero. In this case, summary_factorlist() throws an error:

colon_s$sex2 <- 0
explanatory <- c("age", "age.factor", "sex2", "obstruct.factor")
dependent <- "perfor.factor"
colon_s %>%
  summary_factorlist(dependent, explanatory, p = TRUE)

Confusingly, the function still works in the following case where you have a factor with only 1 unique level:

colon_s$sex.factor2 <- factor("Female")
explanatory <- c("age", "age.factor", "sex.factor2", "obstruct.factor")
dependent <- "perfor.factor"
colon_s %>%
  summary_factorlist(dependent, explanatory, p = TRUE)

from finalfit.

ewenharrison avatar ewenharrison commented on July 29, 2024

Thanks for your continued help with this Graeme. I don't think I'm seeing what you are seeing with this. Seems ok to me:

> colon_s$sex2 <- 0
> explanatory <- c("age", "age.factor", "sex2", "obstruct.factor")
> dependent <- "perfor.factor"
> colon_s %>%
+ 	summary_factorlist(dependent, explanatory, p = TRUE)
        label      levels          No         Yes     p
1 Age (years)   Mean (SD) 59.8 (11.9) 58.4 (13.3) 0.578
2         Age   <40 years   68 (97.1)     2 (2.9) 1.000
3             40-59 years  334 (97.1)    10 (2.9)      
4               60+ years  500 (97.1)    15 (2.9)      
7        sex2           0  902 (97.1)    27 (2.9)    NA
8                       1     0 (NaN)     0 (NaN)      
5 Obstruction          No  715 (97.7)    17 (2.3) 0.018
6                     Yes  166 (94.3)    10 (5.7)      
Warning message:
In chisq.test(tab, correct = FALSE) :
  Chi-squared approximation may be incorrect

from finalfit.

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.