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

arnaud gaboury @rn@ud@g@boury @end|ng |rom gm@||@com
Mon Oct 16 16:29:32 CEST 2023


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

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list