[R-SIG-Finance] from a list of array to tibble

Adam Ginensky @d@mno227 @end|ng |rom gm@||@com
Tue Oct 17 14:51:50 CEST 2023


Perhaps you should have used 'The trouble with tibbles" as your subject
line :)

On Tue, Oct 17, 2023 at 6:21 AM Enrico Schumann <es using enricoschumann.net>
wrote:

> On Mon, 16 Oct 2023, arnaud gaboury writes:
>
> > I work with a list of crypto assets daily closing prices in xts class.
> Here
> > is a limited example:
> >
> > asset.xts.lst <- list(BTCUSDT = structure(c(26759.63, 26862, 26852.48,
> > 27154.15,
> > 27973.45), dim = c(5L, 1L), index = structure(c(1697068800, 1697155200,
> > 1697241600, 1697328000, 1697414400), tzone = "UTC", tclass = "Date"),
> class
> > = c("xts",
> > "zoo")), ETHUSDT = structure(c(1539.61, 1552.16, 1554.94, 1557.77,
> > 1579.73), dim = c(5L, 1L), index = structure(c(1697068800, 1697155200,
> > 1697241600, 1697328000, 1697414400), tzone = "UTC", tclass = "Date"),
> class
> > = c("xts",
> > "zoo")), TRXUSDT = structure(c(0.08481, 0.08549, 0.08501, 0.08667,
> > 0.08821), dim = c(5L, 1L), index = structure(c(1697068800, 1697155200,
> > 1697241600, 1697328000, 1697414400), tzone = "UTC", tclass = "Date"),
> class
> > = c("xts",
> > "zoo")))
> >
> > I will compute some function from PerformanceAnalytics package and write
> > all results in a tibble. Let's apply a first function,
> Return.annualized()
> > (at first I computed returns from daily prices). I have now a list of
> > arrays named my.ret.lst:
> >
> > my.ret.lst <- list(BTCUSDT = structure(15.36, dim = c(1L, 1L), dimnames =
> > list(
> >     "Annualized Return", NULL)), ETHUSDT = structure(4.06, dim = c(1L,
> > 1L), dimnames = list("Annualized Return", NULL)), TRXUSDT =
> structure(10.9,
> > dim = c(1L,
> > 1L), dimnames = list("Annualized Return", NULL)))
> >
> > Now I can't find a way to start my tibble. The idea is to have variables
> > BTCUSDT, ETHUSDT and TRXUSDT (token names), with observations (like
> > annualized return) and the respective values. I will add of course many
> > other observations.My row names can be either my token names, or the
> > observation (annualized return).
> > In my example, I can't find a way to pass each list element name to the
> > wanted tibble.
> >
> > Thank you for help
> >
>
> Do you mean something like this?
>
>     data.frame(my.ret.lst)
>     ##                   BTCUSDT ETHUSDT TRXUSDT
>     ## Annualized Return   15.36    4.06    10.9
>
> (I don't use tibbles, but there is probably an 'as.tibble' method or
>  similar.)
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list