-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all - I'm trying to format some data where I only need one of the values returned from a test, say a t-test in this instance. I have the following: > R.version.string [1] "R version 1.9.0, 2004-04-12" > x <- rnorm(1001) > t.test(x)$statistic t 0.5555321 > Any easy way (other than straight calculation) to get the t-statistic w/o the 't' above it? TIA - -- chris ciotti (chris_ciotti at yahoo.com) PGP ID: 0xE94BB3B7 -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBQIBotlkgIqbpS7O3EQIt7ACdEhhoM3tqqmDae71Rdo/eHg2TvoQAoLSw 8QjwkHENOjjs5mzCWlXSTQXO =LvW5 -----END PGP SIGNATURE-----
as.numeric() (and its siblings) strip the names from vectors, e.g.: > as.numeric(t.test(rnorm(1001))$statistic) [1] -0.6320304 > hth, Tony Plate At Friday 05:14 PM 4/16/2004, christopher ciotti wrote:>-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >Hello all - > > >I'm trying to format some data where I only need one of the values >returned from a test, say a t-test in this instance. I have the following: > > > R.version.string >[1] "R version 1.9.0, 2004-04-12" > > x <- rnorm(1001) > > t.test(x)$statistic > t >0.5555321 > > > >Any easy way (other than straight calculation) to get the t-statistic w/o >the 't' above it? TIA > >- -- >chris ciotti (chris_ciotti at yahoo.com) >PGP ID: 0xE94BB3B7 > > >-----BEGIN PGP SIGNATURE----- >Version: PGP 8.0 > >iQA/AwUBQIBotlkgIqbpS7O3EQIt7ACdEhhoM3tqqmDae71Rdo/eHg2TvoQAoLSw >8QjwkHENOjjs5mzCWlXSTQXO >=LvW5 >-----END PGP SIGNATURE----- > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
How about this? t.test(x)[[1]] The result of t.test(x) is a list and "statistic" is the first component of that list. christopher ciotti wrote:> ... > I'm trying to format some data where I only need one of the values > returned from a test, say a t-test in this instance. I have the following: > > > R.version.string > [1] "R version 1.9.0, 2004-04-12" > > x <- rnorm(1001) > > t.test(x)$statistic > t > 0.5555321 > > > > Any easy way (other than straight calculation) to get the t-statistic > w/o the 't' above it? TIA > ...-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tony Plate wrote: > as.numeric() (and its siblings) strip the names from vectors, e.g.: > > > as.numeric(t.test(rnorm(1001))$statistic) > [1] -0.6320304 > > > > hth, > > Tony Plate Thanks for the quick response. - -- chris ciotti (chris_ciotti at yahoo.com) PGP ID: 0xE94BB3B7 -----BEGIN PGP SIGNATURE----- Version: PGP 8.0 iQA/AwUBQIBqXlkgIqbpS7O3EQKNRwCfREBcPiBQDxIKcnUD6uVJyt5YP/wAnjBR l+C3+RSz2r0juvBZ87DTyyRI =S8Mz -----END PGP SIGNATURE-----
Sorry, I should have checked that more closely. I see that t.test(rnorm(12))[[1]] retains the "t". christopher ciotti wrote:> ... > I'm trying to format some data where I only need one of the values > returned from a test, say a t-test in this instance. I have the following: > > > R.version.string > [1] "R version 1.9.0, 2004-04-12" > > x <- rnorm(1001) > > t.test(x)$statistic > t > 0.5555321 > > > > Any easy way (other than straight calculation) to get the t-statistic > w/o the 't' above it? TIA > ...-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894