guys!
I need to use the function Return.calculate(), in my dataframe, but to use this function, first of all, I need to convert my dataframe to xts.
This is my dataframe:
head(df) datas preco ticker empresa1 20180102 32.09 BBAS3 BRASIL2 20180103 33.10 BBAS3 BRASIL3 20180104 33.52 BBAS3 BRASIL4 20180105 33.70 BBAS3 BRASIL5 20180108 33.64 BBAS3 BRASIL6 20180109 33.59 BBAS3 BRASIL
When I try to convert my dataframe to xts using as.xts() or xts() I receive the following messages:
using as.xts():
Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format
using xts()
Error in xts(z) : order.by requires an appropriate time-based object
What can I do to transform my dataframe in a xts object?
Many thanks