[R] how do I transform this to a for loop

Setlhare Lekgatlhamang SetlhareL at bob.bw
Wed Sep 8 07:36:10 CEST 2010


Hi Bill,
There is a problem with the for loop. When I copied and pasted in my R
console it could not run, instead I got an error message "Error in
NCOL(x) : object 'data.ts' not found".

Lexi


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Bill.Venables at csiro.au
Sent: Monday, September 06, 2010 6:17 AM
To: gaut222 at yahoo.com; r-help at r-project.org
Subject: Re: [R] how do I transform this to a for loop


sseq <- c(1, seq(5, 40, by = 5))
for(i in 1:length(sseq)) 
assign(paste("arima", i, sep=""), arima(data.ts[sseq[i]:(sseq[i]+200)],
order=c(1,1,1)))

...but why would you want to do so?
        

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of lord12
Sent: Monday, 6 September 2010 10:57 AM
To: r-help at r-project.org
Subject: [R] how do I transform this to a for loop


arima1 <- arima(data.ts[1:201], order = c(1,1,1))
arima2 <- arima(data.ts[5:205], order = c(1,1,1))
arima3 <- arima(data.ts[10:210], order = c(1,1,1))
arima4 <- arima(data.ts[15:215], order = c(1,1,1))
arima5 <- arima(data.ts[20:220], order = c(1,1,1))
arima6 <- arima(data.ts[25:225], order = c(1,1,1))
arima7 <- arima(data.ts[30:230], order = c(1,1,1))
arima8 <- arima(data.ts[35:235], order = c(1,1,1))
arima9 <- arima(data.ts[40:240], order = c(1,1,1))

-- 
View this message in context:
http://r.789695.n4.nabble.com/how-do-I-transform-this-to-a-for-loop-tp25
27816p2527816.html
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.

______________________________________________
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.



DISCLAIMER:\ Sample Disclaimer added in a VBScript.\ ...{{dropped:3}}



More information about the R-help mailing list