英文:
Is there any way to set significant level based on 'p.adj' instead of 'p.format' when using compare_means function in R
问题
You can set the significant level based on "p.adj" instead of "p.format" by specifying the "p.adjust.method" argument within the compare_means
function. Here's the code with the modification:
df_compare <- compare_means(len~supp, data=ToothGrowth, method = "wilcox.test", paired = TRUE,
group.by = "dose", p.adjust.method = "holm")
To use the report
function from the "report" package for this output, you can do the following:
library(report)
report(df_compare)
This will generate a report for your comparison output using the "report" package.
英文:
required package : install.packages("ggpubr")
library(ggpubr)
data("ToothGrowth")
df_compare <- compare_means(len~supp, data=ToothGrowth, method = "wilcox.test", paired = TRUE,
group.by = "dose")
My question is how I can set the significant level based on 'p.adj' instead of 'p.format' because I want to add 'p.signif' on my plot but based on 'p.adj' ,and second question is how can I use report function from report package for this output? If someone has a suggestion or explanation, I would appreciate.
答案1
得分: 0
以下是已翻译的内容:
首先,我查看了帮助页面,看是否可以找到一个简单的参数来设置。很不幸,没有这样的运气。然后,我查看了代码,看是否有一个未记录的通向幸福的路径。同样,没有成功。所以我找到了构建p.signif
值的代码部分,然后逆向查找了参数是如何获取的,最后对这些值应用了base::p.adjust
。(只更改了一行代码。然后,我将环境设置为与compare_means
相同。成功。
英文:
First I looked at the help page to see if I could find a simple parameter to set. No such luck. Then I looked at the code to see if there were an undocumented route to happiness. Again, no joy. So I found the section of code where the p.signif
value was constructed and then worked backward to see whee the arguments were obtaine and finally applied base::p.adjust to those values. (It was an alteration of one line. Then I set the environment to the same as compare_means
. Success.
compare_means # code appears on console
compare_means_adj <- # edit a copy of the code scraped from console
+ function (formula, data, method = "wilcox.test", paired = FALSE,
+ group.by = NULL, ref.group = NULL, symnum.args = list(),
+ p.adjust.method = "holm", ...)
+ {
+ . <- NULL
+ method.info <- .method_info(method)
+ method <- method.info$method
# --- leaving out a couple of pages of code
# --- one finds the relevant code at the very end
symnum.args$x <- p.adjust(res$p)
# --- that was the only line of code that was changed
environment(compare_means_adj) <- environment(compare_means)
(df_compare <- compare_means_adj(len~supp, data=ToothGrowth, method = "wilcox.test", paired = TRUE,
group.by = "dose"))
#------------------------------------
# A tibble: 3 × 9
dose .y. group1 group2 p p.adj p.format p.signif method
<dbl> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
1 0.5 len OJ VC 0.0330 0.066 0.033 ns Wilcoxon
2 1 len OJ VC 0.0137 0.041 0.014 * Wilcoxon
3 2 len OJ VC 1 1 1.000 ns Wilcoxon
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论