set.seed(123)
X <- cbind(runif(100), runif(100), runif(100)) # x, y, t
X_shifted <- random.shift(X)
# Compare original and shifted time values
head(X[,3])
head(X_shifted[,3])
# Verify shift visually
plot(X[, 3], type = "o", col = "blue", ylab = "Time", xlab = "Index",
main = "Original vs Shifted Times")
lines(X_shifted[, 3], type = "o", col = "red")
legend("topright", legend = c("Original", "Shifted"),
col = c("blue", "red"), lty = 1, pch = 1)
Run the code above in your browser using DataLab