You want wordspace::dist.matrix .
It accepts sparse matrices from the Matrix package (which is not clear from the documentation), and can also perform cross distances, output Matrix and dist objects, etc.
The default distance value is 'cosine' , so be sure to specify method = 'euclidean' if you want to.
source share