[R] FW: question about the pt() calculation

Phil Spector spector at stat.berkeley.edu
Tue Jan 25 23:52:15 CET 2011

Matthew -
    Others will probably tell you about the folly of performing
1733 t-tests on groups with 4 observations each, but an alternative
to your approach would be to use R to solve your problem.  (I'm
using var.equal=TRUE because that's what you're calculating, but
you might consider using the default behaviour assuming unequal

onerow = function(i){
    thetest = t.test(noncancer[i,],cancer[i,],var.equal=TRUE)
    c(thetest$statistic,thetest$p.value,as.numeric(thetest$p.value < 0.05))

answer = t(sapply(1:nrow(cancer),onerow))

Then answer should have the information that you want.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu

On Tue, 25 Jan 2011, Leitch, Matthew C. wrote:

> From: Leitch, Matthew C.
> Sent: Monday, January 24, 2011 6:53 PM
> To: 'info at network-theory.co.uk'
> Subject: question about the pt() calculation
> Hello
> Thank you for your time. I am a graduate student at the University of Texas Medical Branch, and I was wondering if you could help me with a R program I am writing. I have some data that is stored a file that has 1733 rows and 4 columns. Each row is independent, so I have a loop system so I don't have to manually perform 1733 t-tests. However I got most of it to work, thanks to the "An Introduction to R" book and a helpful colleague. But I am having some difficulty with getting my t-test scores converted to p-values. The pt() test won't take the t object, but I am unsure how to make it create a p-value for each row. If you have any suggestions they would be greatly appreciated.
> Best Wishes
> Matt

More information about the R-help mailing list