-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hi Ben,
I hope this message find you well I was wondering if you have an example on how to use "categorical" render function in ttt.
Sometimes I try to replicate what table1 does in ttt when I need more splits and flexibility. I did not know how to make a render function compatible with ttt as render.categorical.default is not compatible edited it by removing the extra row and now it works
but wanted to hear from the expert !
library(table1)`
library(ttt)
library(ggplot2)
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$vs <- as.factor(mtcars$vs)
mtcars$am <- as.factor(mtcars$am)
table1(~cyl|eqcut(mtcars$mpg,2,varlabel = "mpg")+vs, data=mtcars,overall = FALSE)
table1(~cyl|eqcut(mtcars$mpg,2,varlabel = "mpg")+ paste(vs,am,sep = "/"), data=mtcars,overall = FALSE)
ttt(data = mtcars,cyl~ 1 | eqcut(mtcars$mpg,2,varlabel= "mpg")+ vs + am,
render=paste, collapse="<br/>")
ttt(data = mtcars,cyl~ vs + am| eqcut(mtcars$mpg,2,varlabel= "mpg"),
render=paste, collapse="<br/>")
render.categorical.sm <- function (x, ..., na.is.category = TRUE)
{
unlist(c(sapply(
stats.apply.rounding(stats.default(x, ...),...),
function(y) with(y, sprintf("%s (%s%%)", FREQ,if (na.is.category) PCT else PCTnoNA)))))
}
ttt(data = mtcars,cyl~ vs + am| eqcut(mtcars$mpg,2,varlabel= "mpg"),
render=render.categorical.sm, collapse="<br/>",
expand.along = "rows")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels