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

Adjusted p-values in extra column #129

Open
myjulo opened this issue Jul 30, 2024 · 1 comment
Open

Adjusted p-values in extra column #129

myjulo opened this issue Jul 30, 2024 · 1 comment

Comments

@myjulo
Copy link

myjulo commented Jul 30, 2024

Is there a way to apply a p-value adjustment on all p-values in the extra column? For by incorporating the p.adjust function somewhere? I am assuming that the pvalue function from the vignette is doing it's calculations per row, so it wouldn't make sense there. Is it possible anywhere in the arguments for the table1 function?

pvalue function from the vignette:
pvalue <- function(x, ...) {
# Construct vectors of data y, and groups (strata) g
y <- unlist(x)
g <- factor(rep(1:length(x), times=sapply(x, length)))
if (is.numeric(y)) {
# For numeric variables, perform a standard 2-sample t-test
p <- t.test(y ~ g)$p.value
} else {
# For categorical variables, perform a chi-squared test of independence
p <- chisq.test(table(y, g))$p.value
}
# Format the p-value, using an HTML entity for the less-than sign.
# The initial empty string places the output on the line below the variable label.
c("", sub("<", "<", format.pval(p, digits=3, eps=0.001)))
}

table1 example from the vignette:
table1(~ age + race + married + nodegree + re74 + re75 + re78 | treat,
data=lalonde, overall=F, extra.col=list(P-value=pvalue))

Link: https://cran.r-project.org/web/packages/table1/vignettes/table1-examples.html#example-a-column-of-p-values

@myjulo
Copy link
Author

myjulo commented Sep 17, 2024

I posted a slightly adjusted version of the question above on Stackoverflow:
https://stackoverflow.com/questions/78993102/r-table1-package-adjusted-p-values-in-extra-column

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