Say I have two data sets. Ill call my first set train and here are the variables
month = c(1,1,1,2,2,2,3,3,3,4,4,4)
day=c(3,8,12,3,8,12,3,8,12,3,8,12)
trend=c(0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1,0.2,0.3,0.4)
train=cbind(month,day,trend)
And say my second set is called test, which has month and day variables
tsmonth = c(1,2,2,3,3,3,4,4,4)
tsday=c(3,3,12,3,8,12,3,8,12)
now i want to fill in my trend portion of the test set using values from training data
for example:
in my test set, January 3rd, had a trend value of 0.1
there the first value in my test should be 0.1
so in the end I should get a
tstrend = 0.1, 0.4, 0.4....so on
I tried to code up something like this but it gave me an error msg and I don't really know what to change here
tstrend=rep(0,length(tsmonth))
for (i in 1:length(tsmonth)){
for (j in 1:length(month)){
if (tsday[i] = day[j] & tsmonth[i] =month[j])
{
tstrend[i] = trend[j]
}
}
}
I would really appreciate all your help.
Thank you,
A