> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of azzza > Sent: Monday, October 15, 2007 6:06 PM > To: r-help@r-project.org > Subject: Re: [R] Need some help > > > > Thanks Jholtman. > However, the plot didnt come out the way I envisone dit to be. On the Y > axis, i should have sign changes in 1000 tosses, the range being from > negative to postitive, and a straight horizontal line across y=0. The > X-axis should have the toss number, range 0-1000 >
You would probably get more prompt and useful help if you would provide a small, self- contained example of what you wanted (maybe small enough that you could work it by hand). Also, if you provided some code using the help that you have already received, that would show that you are trying to solve the problem yourself and others could help with the specific R program issues that you are having. For example, it is not clear to me if you want to count the first run of tosses as 0 or 1 sign change. I will assume it is zero. So with that assumption, does this get you what you want? n <- 1000 x <- sample(c(0,1), n, TRUE) y <- rle(x) z <- rep(1:length(y$lengths),y$lengths) plot(1:n,z-1) Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA ______________________________________________ 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.