For xts objects, binary mathematical and logical operators always align two objects by indices before performing the operation. Therefore, you need to use lagindex alignment for proper alignment if you want to use these operators for observations at different timestamps.
require(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
x$diff50 <- lag(x$Close, 50) - x$Close
, lag.xts lag.ts lag.zoo ( k ), k ( ).
, xts, coredata .
nr <- nrow(symbol)
change <- coredata(Cl(symbol)[nr-50]) - Cl(symbol)[nr]