You could consider `sub` here to avoid the copy, but I am not sure it will be much faster. At least not for moderate sample sizes.