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

2019-02-23 Thread Thomas J. Leeper
That seems great to me. Thank you very much! -Thomas On Sat, Feb 23, 2019 at 11:14 AM Martin Maechler wrote: > > > peter dalgaard > > on Fri, 22 Feb 2019 12:38:14 +0100 writes: > > > It's not a problem per se to put additional information > > into class htest objects (hey,

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

2019-02-23 Thread Martin Maechler
> peter dalgaard > on Fri, 22 Feb 2019 12:38:14 +0100 writes: > It's not a problem per se to put additional information > into class htest objects (hey, it's S3 after all...) and > there is a precedent in chisq.test which returns $observed > and $expected. It seems

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

2019-02-22 Thread peter dalgaard
It's not a problem per se to put additional information into class htest objects (hey, it's S3 after all...) and there is a precedent in chisq.test which returns $observed and $expected. Getting such information printed by print.htest is more tricky, although it might be possible to (ab)use

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

2019-02-22 Thread Martin Maechler
> Thomas J Leeper > on Thu, 21 Feb 2019 22:21:21 + writes: > 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

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

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")

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