[R] What' wrong?

Thomas W Blackwell tblackw at umich.edu
Thu May 1 21:34:29 CEST 2003


Two suggestions:

(1) Initialize "result" before the loop by

result <- matrix(0, nrows, ncols)

(2) Truncate the values in "prob" by

prob <- ifelse(prob <= 0, 0.0000001,
	ifelse(prob >= 1, 0.9999999, prob))

HTH  -  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Thu, 1 May 2003, Song, Guangchun wrote:

>
> I try to do single proportion test on my category data.  Here is my R
> script:
>
>
> library("ctest")
>
> catSignifTest <- function( catFile ) {
>     ###############################################################
>     ##  Get the data sets from text file
> 	catData <- read.table( catFile )
>
>
> 	ncols <- length(catData)
> 	nrows <- length(catData[,1])
> 	ncol1 <- ncols - 1
>
> 	probeNbr <- catData[1,]
> 	Achip <- catData[,ncols]
>
> 	for ( row in 2:nrows ) {
> 		prob <- Achip[ row ] / Achip[ 1 ]
>       	if ( prob <= 0 ) prob <- 0.0000001
>       	if ( prob >= 1 ) prob <- 0.9999999
>       	chip <- catData[row,]
> 		for ( col in 1:ncol1 )	{
> 			succ <- chip[col]
> 			trial <- probeNbr[col]
> 			print ( c(row, col, succ, trial, prob ) )
>       		mytest <- prop.test( succ, trial, prob )
>       		result [ row, col ] = mytest$p.value
>       	}
> 	}
> 	print ( result )
> }
>
> Here are the result:
>
> > source("D:/song/R/Test/AML/test_GO_probes.R")
> > catSignifTest( 'GOcat.txt')
> [[1]]
> [1] 2
>
> [[2]]
> [1] 1
>
> $V1
> [1] 6
>
> $V1
> [1] 30
>
> [[5]]
> [1] 0.1539431
>
> Error in min(..., na.rm = na.rm) : invalid "mode" of argument
> >
>
> Could somebody tell me what's wrong?
>
>
> Thanks.
>
> Guangchun
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>



More information about the R-help mailing list