How to implement clustering on categorical feature vectors in R?
You should use dummy variables and then you can toss it directly into K-means. If you have a lot of categories the efficient way to do this is through a one-hot-encoding (sparse-encoding).

Here's a little demo using clustering and then using the clusters in a regression model. In general, you should avoid doing that but it's illuminating in this case.

library(glmnet)
library(Matrix)
n &lt;- 1e5
nclusters &lt;- 5
set.seed(420)
ls &lt;- data.frame(sample(letters, n, replace=TRUE))
xs &lt;- sparse.model.matrix(~.,data=ls)
print(head(xs))  
# Now let's run k-means
out &lt;- kmeans(xs, centers=nclusters)
bs &lt;- rep(1, dim(xs)[2])
# Let's run k-means on the different categories
clusterpred &lt;- data.frame(out[[1]])
ys &lt;- xs %*% bs + rnorm(n)
print(table(clusterpred))
# Now let's use a clustered data set to predict some outcome
cxs &lt;- sparse.model.matrix(~.,data=clusterpred)
model &lt;- glmnet(y=ys, x=xs, alpha=0)
cmodel &lt;- glmnet(y=ys, x=cxs, alpha=0)

# Predictions
yhat &lt;- predict(model, xs)
yhatc &lt;- predict(cmodel, cxs)
# Looking at the difference RMSEs 
print(sqrt( sum( (ys-yhat)**2 )))
print(sqrt( sum( (ys-yhatc)**2 )))