[ad_1]

I need to calculate each component of the time series for each X (50 levels) and Y (80 levels) from my dataset (df).

I wanted to go with something akin to:

```
for (i in 1:df$X) {
for (j in 1:df$Y) {
TS <- ts(df$Mean, start = c(1998, 1), end = c(2015, 12), frequency = 12)
TSD <- decompose(TS, type = c("additive"))
}
}
```

But this is not working. Error message is:

“Error in 1:df$X : NA/NaN argument In addition: Warning messages: 1: In

1:df$X : numerical expression has 50 elements: only the first used 2: In

1:df$X : NAs introduced by coercion”

Similar data:

```
X Y Mean Date(mY)
Tru A 35.6 02.2015
Fle A 15 05.2010
Srl C 67.1 05.1999
Tru A 13.2 08.2006
Srl B 89 08.2006
Tru B 14.8 12.2001
Fle A 21.5 11.2001
Lub D 34.8 03.2000
```

[ad_2]