When I try to calculate table.Drawdowns (PerformanceAnalytics package) for one asset, all works fine. But I struggle to use a larger dataset with more than one asset.
First, this code works fine for one asset. The csv contains a date column followed by a return column:
A1 <- read_csv("A.csv", col_types = cols(Date = col_date(format = "%d/%m/%Y")))
df<-xts(A1$Stock1, order.by=as.Date(A1$Date))
table.Drawdowns(df)
Next, let's add another stock in the csv file:
A2 <- read_csv("A.csv", col_types = cols(Date = col_date(format = "%d/%m/%Y")))
df<-xts(A2[,2:3], order.by=as.Date(A2$Date))
table.Drawdowns(df)
table.Drawdowns(df$Stock1)
table.Drawdowns(df[,1])
table.Drawdowns(df[,-2])
where all four attempts lead to "non-numeric argument to binary operator". So probably something is wrong in using xts for more than one column. I also tried to convert the dataframe to numeric:
df2<-as.numeric(df[,1])
table.Drawdowns(df2[,1])`
but the error stays the same.
The final purpose would have an csv file of n assets and get the table.drawdowns for each of them at one go.