I have looked far and wide for a solution to this issue, but I cannot seem to figure it out. I do not have much experience working with xts objects in R.
I have 40 xts objects (ETF data) and I want to run the quantmod function WeeklyReturn
on each of them individually.
I have tried to refer to them by using the ls()
function:
lapply(ls(), weeklyReturn)
I have also tried the object()
function
lapply(object(), weeklyReturn)
I have also tried using as.xts()
in my call to coerce the ls() objects to be used as xts but to no avail.
How can I run this function on every xts object in the environment?
Thank you,