Closed EddieItelman closed 4 years ago
Print for TableOne or ContTable expects a character vector of variable names. As is stated in the help files (run ?tableone::print.TableOne
and ?tableone::print.ContTable
).
You could try to run the example from the Readme. Which uses the nonnormal option exactly as you suggested:
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), smd = TRUE)
If you ran into a bug, please provide more information about the error.
This is exactly what I said. The argument at the function level expects a named list and the argument in the print method expects a vector.
Is this the true expected behavior?
The option argsNonNormal =
of CreateTableOne
is used to provide arguments for the kruskal.test or any other function you provide under testNonNormal =
.
P values are always calculated using both normal and non-normal functions for every continuous variable. Which p value gets displayed is controlled by the nonnormal =
option of print.TableOne
.
It is only for rare use cases. For example if you would like to calculate the ANOVA for some variables without the equal variances option.
library(survival); library(tableone); data(pbc)
vars <- names(pbc)[-1]
tableOne <- CreateTableOne(vars = vars, strata = c("trt"), data = pbc,
testNonNormal = oneway.test, argsNonNormal = list(var.equal = FALSE))
print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"),
exact = c("status","stage"), smd = TRUE)
Now the p values for the non-normal vars are calculated using oneway.test
with var.equal=FALSE
. Please check ?oneway.test
for more information.
TLDR: Ignore the option argsNonNormal
. You only have to provide the non-normal variables to the print
function.
when calling the argument argsNonNormal it expects a named list. Creating a named list in R is much more complex then simply passing a vector of names.
This is why I personally create the object first and then print it with the non_normal names vector like so: print(tab1, nonnormal = vector_of_non_normal_vars) where the vector looks like: c("Age","Sodium","Haemoglobin")
It will be much easier if you set it to expect a vector instead of a named list.