On Tue, Jul 6, 2010 at 11:02 AM, Edwin Groot <
edwin.groot@biologie.uni-freiburg.de> wrote:

> Hello all,
> I am trying to repeat a hypergeometric test 40 times by putting it in a
> loop, but I am missing something as it does not work.
> How do I substitute a slot name with a string variable?
>
> Here is the code so far:
> > probTable <- data.frame(row.names=rownames(repData))
> > for (dataset in rownames(sizeData)) {
> + probVector <- phyper(repData$`dataset`-1,
>

Hi, Edwin.

repData[,dataset]


> + repData$size, totalGenes-repData$size,
> + sizeData[`dataset`,], lower.tail = FALSE);
>

sizeData[dataset,]

> probTable$`dataset` <- probVector }
>
>
probTable[,dataset]


> Error in `$<-.data.frame`(`*tmp*`, "dataset", value = numeric(0)) :
>  replacement has 0 rows, data has 492
>
> The point here is that backticking is not working for me:
> repData$`dataset` returns NULL.
> I tried variations on single quotes, substitute(), eval() and evalq(),
> but none work!
>

You might benefit from a quick primer on R subsetting.  The Intro to R
manual is one place to start.

Sean



>
> FYI the sizeData object is a data frame of 40 rows. The repData object
> is a data frame of 492 rows and 41 columns. The names of 40 of the
> columns are identical to the names of the 40 rows in sizeData.
>
> TIA for helping me out of a mental block,
> Edwin
> p.s. R 2.11.1 i486 linux-gnu; Bioc err... 2.6
> --
> Dr. Edwin Groot, postdoctoral associate
> AG Laux
> Institut fuer Biologie III
> Schaenzlestr. 1
> 79104 Freiburg, Deutschland
> +49 761-2032945
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

