# How do I create clusters with a completely categorical data?

I am working on the project that requires data mining. I have been asked to use R. I have a dataset with all categorical variables and would like to form clusters on that. I am unable to figure out how to do so in R.

Here is what I have done: I have converted all the variables to "factor" data type in R. But I am not able to see the underlying numbered levels. I also do not know how to use this with kmeans() to get the required result.

My question is how do I form clusters on these factors.

Here is what the data looks like:

RowNum|EmpNum|EmpName|EmpOrganization|EmpTitle|EmpLeaderNumber|EmpDepartment|EmpAccesstoApplicaton|EmpAccessID The entire data is 14MB.

The effort is to cluster people with similar access. So people with similar Title or in similar org might have similar access. I understand kmeans() isn't the best option, but that is what I would like to use for the first draft.

I converted the EmpOrganization, EmpTitle etc to numeric data in excel using simple vlookup. It is easy to convert these to indicator variables using if statement in excel but I'm hoping that there is a more efficient way to do this in R itself.

• Can you show the code you do have? – doctorlove Aug 19 '14 at 17:50
• Surely something like fit <- kmeans(mydata, 5) for 4 clusters works? See statmethods.net/advstats/cluster.html – doctorlove Aug 19 '14 at 17:55
• Do you just not know how to do this in R? Or do you not know how to do this in any language? If you want suggestions for methods on clustering categorical data, you're better off asking at Cross Validated; that is not a specific programming question. – MrFlick Aug 19 '14 at 18:12
• you have to specify what the required result is. is there any relationship between the categorical variables (eg hierarchies). what should the clusters represent? do you want to identify groups of roughly equal frequency, or do you actually have a supervised learning problem, where you want to find 'clusters' that have the similar effect ( in which case you are better off with a tree building package such as rpart) – seanv507 Aug 20 '14 at 7:47
• Are the categories ordinal or nominal? – Glen_b Aug 20 '14 at 7:55