I'm trying to use R to measure stock performance. The sample code is from here: https://towardsdatascience.com/how-to-measure-stock-portfolio-performance-using-r-847c992195c2
In the section of code below we're trying to gather separate data into a single xts object. However, the resulting xts object would only list data from one date, rather than the entire date range that was specified. Sample code below:
# IDX-BUMN20 Create Dataframe
Index <- list(AAPL, NLY, FVRR)
names(Index) <- IDXBUMN20
Index <- lapply(Index, '[', i = 1, j = 6) # select only Adjusted close price
Index <- do.call(cbind.data.frame, Index) #List to Dataframe
names(Index) <- IDXBUMN20 # change colnames
Index <- as.xts(Index)
Thank you very much for your help, novice here.