Skip to content
Prev 168527 / 398502 Next

[SPAM] - Re: for/if loop - Bayesian Filter detected spam

Well, maybe you are just bad at typing then ;-)

The lines rr==ii, pp==pp+1, etc. are not setting rr and pp but comparing
them.
Probably you want rr <- ii and pp <- pp+1, etc.
And the last line of your loop 'ii=ii+1' means that,
since the for statement is already incrementing ii,
you are incrementing it twice and skipping the even indices. Omit this
line probably.
You are also forgetting(?) the operator precedence in
sum(lselb1[rr:ii-1]) and similar lines.
Note that this is equivalent to sum(lselb1[(rr-1):(ii-1)]); is that what
you meant?
Or did you want sum(lselb1[rr:(ii-1)])?
You are changing some variables but not asking R to print anything as
far as I can see.
To see the results, ask R to print hll.

HTH,
-- David

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of SnowManPaddington
Sent: Wednesday, January 28, 2009 3:59 PM
To: r-help at r-project.org
Subject: [SPAM] - Re: [R] for/if loop - Bayesian Filter detected spam


Hi ya, I've revised the code (and finally know what I m doing.. :-D)

The good news is.. I dont get any error message, but the bad news is the
following optim generate no results. I still think there is something to
do
with my loop... can anyone advice? Thanks again!!!



pp=1
rr=1

for (ii in 1:n){
	if (!(panel[ii] == pp)){
		hll[pp,1] == sum(lselb1[rr:ii-1])
		hll[pp,2] == sum(lselb2[rr:ii-1])
		rr==ii
		pp==pp+1
		}
	
	if (ii==n){
		hll[pp,1] == sum(lselb1[rr:ii])
		hll[pp,2] == sum(lselb2[rr:ii])
		rr==ii
		pp==pp+1
		}
	ii=ii+1
}





pp=1
rr=1

for (ii in 1:n){
	if (!(panel[ii] == pp)){
		hll[pp,1] == sum(lselb1[rr:ii-1])
		hll[pp,2] == sum(lselb2[rr:ii-1])
		rr==ii
		pp==pp+1
		}
	
	if (ii==n){
		hll[pp,1] == sum(lselb1[rr:ii])
		hll[pp,2] == sum(lselb2[rr:ii])
		rr==ii
		pp==pp+1
		}
	ii=ii+1
}
SnowManPaddington wrote:
loop
panel
I
language
know