[R] extracting the t-statistic: just the numbers, please
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Jul 29 08:31:16 CEST 2004
Michael Rennie <mrennie at utm.utoronto.ca> writes:
> > simt
> t t t t t t t
> 0.3474150 0.1542973 -0.4044992 1.2466663 -0.2933944 -0.5809257 0.7799080
> t t t
> -1.4132713 1.2048335 -0.6596936
>
> Which gives me a list, but not in a form that I can do anything with. This is
> in stark contrast to what happens when requesting p-values, which gives output
> like this:
..
> > simt
> [1] 0.6763749 0.7480091 0.9447851 0.3342029 0.7852635 0.3199006 0.5272153
> [8] 0.3863616 0.7333693 0.7268907
>
> Now THAT'S what I'd like to get for my t-statistics- a nice vector (simt) that
> I can deal with later, rather than the output I am currently getting (the first
> output above).
>
> Does anyone know a way to extract JUST the t-statistics from the t.test,
> without the "t" character header, so I can generate a nice little vector?
> Alternatively, can I manipulate the output I am currently getting for the t-
> statistics so that I can isolate just the numbers?
It *is* a nice little vector! It's just that it has names.
names(simt) <- NULL
gets rid of them.
BTW, simt <- c(simt, sims) is going to kill performance with large repeat
counts since it copies all previous results every time around.
Preallocate the result, or consider using replicate() or sapply().
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list