Re: [Rd] Return/print standard error in t.test()

2019-02-21 Thread Thomas J. Leeper
Hi John, Thanks for your reply. Of course I could write a package and of course I would find that trivial to do. The point is this is a main entry point to R for probably (at this point) hundreds of thousands of students. I’d like them to be able to get a basic quantity of interest from a t-test w

Re: [Rd] Return/print standard error in t.test()

2019-02-21 Thread Rui Barradas
Hello, Something like this? t.test2 <- function(...) { ht <- t.test(...) class(ht) <- c("htest_tjl", class(ht)) ht } print.htest_tjl <- function(x, ...) { NextMethod(x, ...) se <- as.vector(abs(diff(x$estimate)/x$statistic)) cat("Standard error of the difference:", se, "\n\n") in

Re: [Rd] Return/print standard error in t.test()

2019-02-21 Thread Fox, John
Dear Thomas, it is, unfortunately, not that simple. t.test() returns an object of class "htest" and not all such objects have standard errors. I'm not entirely sure what the point is since it's easy to compute the standard error of the difference from the information in the object (adapting an

[Rd] Return/print standard error in t.test()

2019-02-21 Thread Thomas J. Leeper
A recent thread on Twitter [1] by a Stata user highlighted that t.test() does not return or print the standard error of the mean difference, despite it being calculated by the function. I know this isn’t the kind of change that’s likely to be made but could we at least return the SE even if the pr

Re: [Rd] code for sum function

2019-02-21 Thread Gabriel Becker
Hi all, >From what I can see from my checkout of the Rsources (in src/main/summary.c as pointed out by others) sums are calculated the "naive" way (see rsum c function) but means are actually calculated something akin to the Neumaier way (see real_mean c function). Just an fyi. ~G On Thu, Feb

Re: [Rd] code for sum function

2019-02-21 Thread Ben Bolker
Specifically: https://svn.r-project.org/R/trunk/src/main/summary.c And if you don't want to deal with Subversion, you can look at the read-only github mirror: https://github.com/wch/r-source/blob/e5b21d0397c607883ff25cca379687b86933d730/src/main/summary.c#L115-L131 On Thu, Feb 21, 2019 at 11:57

Re: [Rd] code for sum function

2019-02-21 Thread David Winsemius
On 2/20/19 2:55 PM, Rampal Etienne wrote: Dear Tomas, Where do I find these files? Do they contain the code for the sum function? Yes. https://svn.r-project.org/R/trunk/ David What do you mean exactly with your point on long doubles? Where can I find documentation on this? Cheers, Ram

Re: [Rd] Bug in print.default: dispatches to global show instead of methods::show

2019-02-21 Thread Martin Maechler
> Lionel Henry > on Thu, 21 Feb 2019 12:27:11 +0100 writes: > Hello, > This is already fixed in r-devel, I think by this commit: > https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259

[Rd] Proposed patch for ?Extract

2019-02-21 Thread Marc Schwartz via R-devel
Hi, In follow up to the thread on R-Help yesterday: https://stat.ethz.ch/pipermail/r-help/2019-February/461725.html I am attaching a proposed patch against the trunk version of Extract.Rd, with wording added to the "Matrices and arrays" section, to note that indexing these object by factors

Re: [Rd] model.matrix.default() silently ignores bad contrasts.arg

2019-02-21 Thread Ben Bolker
On Thu, Feb 21, 2019 at 7:49 AM Fox, John wrote: > > Dear Ben, > > Perhaps I'm missing the point, but contrasts.arg is documented to be a list. > From ?model.matrix: "contrasts.arg: A list, whose entries are values (numeric > matrices or character strings naming functions) to be used as replacem

Re: [Rd] code for sum function

2019-02-21 Thread Rampal Etienne
Dear Will, This is exactly what I find. My point is thus that the sum function in R is not a naive sum nor a Kahansum (in all cases), but what algorithm is it using then? Cheers, Rampal On Tue, Feb 19, 2019, 19:08 William Dunlap The algorithm does make a differece. You can use Kahan's summati

Re: [Rd] code for sum function

2019-02-21 Thread Rampal Etienne
Dear Paul, Thank you for thinking with me. I will respond to your options: > > 0/ Your code is wrong, but that seems unlikely on such a simple > calculations. > It's really just a comparison of the sum function in Fortran with that of R. If instead I use the naive summation with a for loop in bo

Re: [Rd] code for sum function

2019-02-21 Thread Rampal Etienne
Dear Tomas, Where do I find these files? Do they contain the code for the sum function? What do you mean exactly with your point on long doubles? Where can I find documentation on this? Cheers, Rampal On Mon, Feb 18, 2019, 15:38 Tomas Kalibera See do_summary() in summary.c, rsum() for doubles.

Re: [Rd] model.matrix.default() silently ignores bad contrasts.arg

2019-02-21 Thread Fox, John
Dear Ben, Perhaps I'm missing the point, but contrasts.arg is documented to be a list. From ?model.matrix: "contrasts.arg: A list, whose entries are values (numeric matrices or character strings naming functions) to be used as replacement values for the contrasts replacement function and whose

Re: [Rd] Bug in print.default: dispatches to global show instead of methods::show

2019-02-21 Thread Lionel Henry
Hello, This is already fixed in r-devel, I think by this commit: https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259

[Rd] Bug in print.default: dispatches to global show instead of methods::show

2019-02-21 Thread Dean Attali
This is related to a problem that was fixed in 2015 https://github.com/wch/r-source/commit/38ea40dcd0353af16d35296ee621338c49ae48c9 The problem then was that auto-printing by typing an object to the console would search for show() in the globalenv instead of in the methods namespace. The problem I