[R] for loops and counters

Peter B. Mandeville mandevip at uaslp.mx
Tue Oct 5 04:34:12 CEST 1999

I am trying to assign values to a vector (pvalue). Similar code works in C
but not in R. What am I doing wrong?

	r <- pvalue <- 0
	for(i in (1:(k-1))){
		for(j in (i+1):k){
			r <- r+1
			tstat <- (means[i]-means[j])/rms
			pvalue[r] <- 2*(1-pt(abs(tstat),df))

Thank you.

Peter B.

Peter B. Mandeville                             mandevip at deimos.tc.uaslp.mx
Jefe del Depto. de Informática y Bioestadística rpe1531 at pasteur.fmed.uaslp.mx 
Facultad de Medicine                            Tel: 48 26-23-45 ext. 232
Universidad Autónoma de San Luis Potosí         Fax: 48 28-23-52
Av. V. Carranza 2405
Col. Los Filtros
Apartado Postal 145
San Luis Potosí, S.L.P.
78210 México

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list