You can use the adjRatios
function in the TTR package to do this. It looks like you already have an xts object, so I'm using:
library(quantmod) x <- structure(c(6111.01, 6145, 6120.01, 6240, 6231, 6279, 6145, 6190, 6250, 6285, 6325, 6295, 6102.7, 5960, 6120, 6225.1, 6231, 6180.01, 6145, 6135.05, 6225, 6261, 6270, 6190, 956, 8771, 10579, 8882, 8015, 8461), .Dim = c(6L, 5L), .Dimnames = list(NULL, c("Open", "High", "Low", "Close", "Volume")), index = structure(c(1041746400, 1042005600, 1042092000, 1042178400, 1042437600, 1042524000), tzone = "", tclass = "Date"), class = c("xts", "zoo"), .indexCLASS = "Date", .indexTZ = "") s <- xts(1/1000,as.Date("2003-01-10")) r <- adjRatios(s,,Cl(x)) OHLC(x) * drop(r[,"Split"]) * drop(r[,"Div"])
If you use data from Yahoo Finance, then you can use the adjustOHLC
function in quantmod to automatically extract split and dividend data from Yahoo and adjust the series. See ?adjustOHLC
more details.