On 24/02/2015 9:11 AM, Linh Nguyen Vaccarello wrote: > I am very new to R and I'm trying to increase my decimal places (from 2 to > 4) for this code: > >> with(longitudinal, pairwise.wilcox.test(DV, Time, > p.adjust.method="holm", > paired=TRUE)) > > Right now the output is: > > Pairwise comparisons using Wilcoxon signed rank test > > data: DV and Time > > yr15 yr2 yr5 > yr2 0.03 - - > yr5 0.03 0.05 - > yr8 0.03 0.05 0.03
Many functions in R produce objects with a class, and there are special methods to print many classes. In the case of pairwise.wilcox.test the object produced is of class "pairwise.htest". You can see the code using stats:::print.pairwise.htest and you'll see it hard-codes 2 significant digits. (Which surprises me a bit, but I guess your p-values are all 0.030 and 0.050.) You can edit the definition for a temporary change: print.pairwise.htest <- function (x, digits = 5, ...) { cat("\n\tPairwise comparisons using", x$method, "\n\n") cat("data: ", x$data.name, "\n\n") pp <- format.pval(x$p.value, digits, na.form = "-") attributes(pp) <- attributes(x$p.value) print(pp, quote = FALSE, ...) cat("\nP value adjustment method:", x$p.adjust.method, "\n") invisible(x) } Your definition of this method will override the default one, so defining that function is enough, R will call it for printing. Duncan Murdoch > > I have tried various codes and they didn't work: > options(digits=4) > with(longitudinal, pairwise.wilcox.test(DV, Time, > p.adjust.method="holm", > paired=TRUE)) > >> with(longitudinal, pairwise.wilcox.test(DV, Time, > + p.adjust.method="holm", > + paired=TRUE), > + options(digits=4)) > >> with(longitudinal, pairwise.wilcox.test(DV, Time, > + p.adjust.method="holm", > + paired=TRUE, > + digits=4)) > >> with(longitudinal, pairwise.wilcox.test(DV, Time, > + p.adjust.method="holm", > + paired=TRUE), > + signif(digits=4)) > > thanks, > Linh > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.