I am doing time series analysis on oil prices in R. In order to complete one of my modeling tasks, a MONTH column next to the closing price of oil each month was added:
df <- cbind(df, MONTH=1:nrow(df))
The output was successful and came out to this:
OILSTOCK MONTH
1 1965 1
2 1812 2
3 1492 3
4 1289 4
5 1256 5
I then have to take a holdout sample on the last 12 months of the data (there are a total of 108 months), I do so with the following:
n_OILSTOCK=OILSTOCK[1:96]
n_MONTH=MONTH[1:96]
The command above works as expected for n_OILSTOCK, but for some reason, I get the following error in regards to n_MONTH:
> n_MONTH=MONTH[1:96]
Error: object 'MONTH' not found
I am unsure why R is not recognizing this new MONTH column as a proper object. Is there an easy way for me to address this? The original data was brought in as .txt format. Thank you for your assistance.