[BioC] Problems substituting slot name with string variable

Edwin Groot edwin.groot at biologie.uni-freiburg.de
Tue Jul 6 17:02:47 CEST 2010


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, 
+ repData$size, totalGenes-repData$size, 
+ sizeData[`dataset`,], lower.tail = FALSE); 
probTable$`dataset` <- probVector }

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!

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



More information about the Bioconductor mailing list