my question is very closely related to a previous post: compute all pairwise differences within a vector in R
But I'm interested in the difference of these elements not the absolute difference, which makes all suggested solutions infeasible.
I know how to obtain a result with this command:
n <- 4
x <- c(1:4)
combn(x,2, FUN=diff)
But this is too slow for my application where n=500/1000/... . What would be the most efficient way to do this in R