"blap.txt" is a numeric vector of length 64.

I am using the following code:


bd<-scan("blap.txt")
output<-matrix(0,64,10)
s<-sum(bd)
for (i in 10){

while (s>0)
{x1<-sample(bd,(length(bd)-1), replace=F)
s<-sum(x1)
bd<-x1
output[i]<-s

}


}
write.table(output, file="res.txt")

This code is not doing what I'd like it to do:

1. It is not running through the while loop 10 times, just once.
2. I can't work out how to get the results into the output matrix. The
matrix should be 10 columns with the decreasing s values for each of the
10 runs through the for loop.

Sorry for any obvious mistakes. I'm very new to R and teaching myself.
Where am I going wrong here, please?

Thank you.


--

______________________________________________
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