[R] if condition and for cycles

Thomas Lumley tlumley at u.washington.edu
Tue Nov 27 23:23:48 CET 2007


In both cases the problem is that you didn't print() the results. This is 
a similar issue to FAQ 7.16, which discusses the problem in more detail.

 	-thomas

On Tue, 27 Nov 2007, ljantunes wrote:

> 
I have two questions about R:

1) Does anyone knows why I get the plots but not the summary results of the
linear fitting when I run this code? When I run it outside the if condition
it works fine.

if (op==4) {
 	t=1:length(time(SeaIce))
 	fitlinear=lm(SeaIce~t)
 	windows()
 	plot.ts(SeaIce)
 	lines(ts(fitlinear$fitted.values,start=1979,frequency=12))
 	summary(fitlinear)
 	fitlinear=ts(fitlinear$fitted.values,start=1979,frequency=12)
 	c=cos(2*pi*t/12)
 	s=sin(2*pi*t/12)
 	fittotal=lm(SeaIce~t+c+s)
 	summary(fittotal)
 	windows()
 	par(mfrow=c(2,1))
 	plot(t,SeaIce)
 	lines(fittotal$fit, col=2)
 	plot(t,fittotal$resid)
 	windows()
 	acf(fittotal$resid)
}

2) Why does't this work? I get the message "I'here" ten times but the AIC
results, none.


for (i in 1:10) {
 	f_arima = arima(SeaIce_STL_Remain,order=c(i,0,0))
 	AIC(f_arima)
 	Message("Iÿÿhere")
}

Thanks in advance,
Luis Antunes

-- 
View this message in context: http://www.nabble.com/if-condition-and-for-cycles-tf4882403.html#a13972845
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle


More information about the R-help mailing list