Closed manisahni closed 9 years ago
The variables you specify in the factorVars have to be also in vars, too. The code below should work. This questions has been asked several times in the past. Maybe I should reconsider this interface.
tableOne <- CreateTableOne(vars = c(vars, factorVars), strata = "unequivocal_pos", data = temp3, factorVars = factorVars)
Thanks much Kazuki. Very cool.
I cant seem to get the categorical variables into the CreateTableone output: any help will be appreciated. You can see below that the dataset contains categorical as well as continuous variables.
https://www.dropbox.com/s/qbw9viacsx774q4/temp3.csv?dl=0 ## link to the dataset https://www.dropbox.com/s/hi3sh82noslktpd/table%20one%20example.Rmd?dl=0
link to the rmd file containing code
setwd("~/Dropbox/tableone example") ## set wd temp3 <- read.csv("~/Dropbox/tableone example/temp3.csv") head(temp3)
Here is the code for making table One.
library(tableone)
factorVars <-c("tachy", "fever", "hypotherm", "luekocytosis", "leukopenia", "tachypnea", "sot", "immunosuppresive", "unequivocal_pos", "neutropenic")
set factor variables
vars<- c("max_wbc", "procal_corr", "max_lact", "max_temp", "max_rr", "max_hr", "min_temp", "max_anc", "min_sbp","sirs_score")
set continous variables
tableOne <- CreateTableOne(vars = vars, strata = "unequivocal_pos", data = temp3, factorVars = (factorVars)) #
tableOne