I applied a different data set to Joshua Ulrich’s answer at previous question (Automatic vlookup and multiply coefficients with R) and it gives an error I haven’t been able to solve.
New dataset:Brazil’s Bovespa index
(sp<-read.csv(“http://www.bolsapt.com/download/historico/%5EBVSP/de-01-01-2000-a-04-02-2013/“)
spLag <- lag(sp)
Error in hasTsp(x) : invalid time series parameters specified
Best regards
@JoshuaUlrich used
getSymbolswhich returns anxtsobject by default.xtsobjects are specifically designed to work with time series data. You’re trying to apply the same code to adata.framewhich is a more general data class. To create anxtsobject, you must provide a timeBased index.The above converts the YYYYMMDD column to proper
Dates and uses that as the index. Note that all columns of anxtsobject must be of the same class, so I only included numeric columns.