Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individual P-values for grouped variables under a heading. #122

Open
TeunAben opened this issue Mar 6, 2024 · 0 comments
Open

Individual P-values for grouped variables under a heading. #122

TeunAben opened this issue Mar 6, 2024 · 0 comments

Comments

@TeunAben
Copy link

TeunAben commented Mar 6, 2024

Dear Benjamin,
Thank you for the package, the tables are absolutely fantastic.
Currently I am trying to make a table in which I have grouped variables under a heading as described in #98 .
The render I used is the following:
rndr <- function(x, name, ...){
if(name=="disease"){
d<- Albumin[x, c("Myocardialinfarction", "Congestiveheartfailure", "Peripheralvasculardisease", "Cerebrovasculardisease", "Chronicpulmonarydisease", "Diabetes", "Liverdisease", "Renaldisease")]
l <-lapply(Albumin, label)[names(d)]
names(d)[!sapply(l,is.null)] <-l[!sapply(l,is.null)]
c("", sapply(d, render.default)[2,,drop=T])
}else if(name =="treatment"){
f<- Albumin[x,c("Steroids", "IL_blockers", "Remdesivir","LMWH", "Albumin")]
k<- lapply(Albumin, label)[names(f)]
names(f)[!sapply(k,is.null)] <-k[!sapply(k,is.null)]
c("",sapply(f,render.default)[2,,drop=T])
}else if(name=="Score"){
g<-Albumin[x,c("CharlsonScore","Admission_SOFA","ICU_day_1_SOFA","Max_SOFA", "SAPS_Total")]
m<-lapply(Albumin,label)[names(g)]
names(g)[!sapply(m,is.null)]<- m[!sapply(m,is.null)]
c("", sapply(g,render.continuous.default)[3,,drop=T])
}else if(name== "HNAfractions"){
h<- Albumin[x,c("HMA","HNA1","HNA2")]
n<-lapply(Albumin,label)[names(h)]
names(h)[!sapply(n,is.null)]<-n[!sapply(n,is.null)]
c("",sapply(h,render.continuous.default)[2,,drop=T])
}else{
render.default(x,name,...)
}
}

or in plain text:

rndr <- function(x, name, ...){
if(name=="disease"){
d<- Albumin[x, c("Myocardialinfarction", "Congestiveheartfailure", "Peripheralvasculardisease", "Cerebrovasculardisease", "Chronicpulmonarydisease", "Diabetes", "Liverdisease", "Renaldisease")]
l <-lapply(Albumin, label)[names(d)]
names(d)[!sapply(l,is.null)] <-l[!sapply(l,is.null)]
c("", sapply(d, render.default)[2,,drop=T])
}else if(name =="treatment"){
f<- Albumin[x,c("Steroids", "IL_blockers", "Remdesivir","LMWH", "Albumin")]
k<- lapply(Albumin, label)[names(f)]
names(f)[!sapply(k,is.null)] <-k[!sapply(k,is.null)]
c("",sapply(f,render.default)[2,,drop=T])
}else if(name=="Score"){
g<-Albumin[x,c("CharlsonScore","Admission_SOFA","ICU_day_1_SOFA","Max_SOFA", "SAPS_Total")]
m<-lapply(Albumin,label)[names(g)]
names(g)[!sapply(m,is.null)]<- m[!sapply(m,is.null)]
c("", sapply(g,render.continuous.default)[3,,drop=T])
}else if(name== "HNAfractions"){
h<- Albumin[x,c("HMA","HNA1","HNA2")]
n<-lapply(Albumin,label)[names(h)]
names(h)[!sapply(n,is.null)]<-n[!sapply(n,is.null)]
c("",sapply(h,render.continuous.default)[2,,drop=T])
}else{
render.default(x,name,...)
}
}

This gave me the result I wanted for grouping like this:
Scherm­afbeelding 2024-03-06 om 10 37 32

However, now I wanted to use statistical tests to see if any significant differences exist between the groups, which probably means I have to reverse the render before it is possible to perform the tests on the groups. Probably this is some really simple coding but I haven't been able to pull it off.
I was wondering if you could possibly help me. If not possible or too hard I can of course do the statistics by hand and add them to the table manually.
Kind regards
Teun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant