Quantcast
Channel: How to convert a data.frame to a xts in R? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to convert a data.frame to a xts in R?

$
0
0

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


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images