[R] Need some help
Daniel Nordlund
res90sx5 at verizon.net
Tue Oct 16 06:18:23 CEST 2007
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of azzza
> Sent: Monday, October 15, 2007 6:06 PM
> To: r-help at 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
More information about the R-help
mailing list