Shuhua Zhan <szhan <at> uoguelph.ca> writes:

> 
> smallvec<-c(8,12,9,6,13,20,16,11,8,5)  
> largevec<-c(400,300,550,600,210,420,380,600,450,500)
> generdm<-c() ## a random set of genes
> for( i in 1:length(smallvec)){
> 
# try to chop down this line and add a print to understand
# what is going on
generdm<-c(generdm,
  
sample(rownames(largedf)[sum(largevec[0:i-)],1):sum(largevec[0:i])],smallvec[i]))

> ## rownames(largedf) gives gene names ordered by levels in 
> }

Since your code does not run, and you do not show how you got your 
result, it is a bit of guesswork. I believe it has nothing to do with 
sample(), but rather with the way you "store" (=not store) the results. 
Your way of storing looks a bit like PHP.

Try a variation of this one

generdm = list()
for (i in 1:10)
{
  generdm[[i]] = rnorm(10) # put your sample construct here
}
generdm

Dieter

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to