calculating probability or filtering that certain subject is not in the particular cluster I have a situation where there are n individuals and p features (variables). I do have their cluster information. Here is an example:
myd <- data.frame (
 sub1 = c(1, "AB", "AB", "BB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub2 = c(1, "AB", "BB", "BB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub3 = c(1, "AB", "BB", "AB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub4 = c(1, "AB", "BB", "AB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub5 = c(1, "AB", "BB", "BB", "AB", "AB", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub6 = c(1, "AB", "BB", "BB", "BB", "AA", "AB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub7 = c(2, "AA", "AA", "BB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub8 = c(2, "AB", "AA", "AB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub9 = c(2, "AA", "AA", "BB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub10 = c(2, "AB", "AA", "BB", "AB", "AA", "BB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub11 = c(2, "AA", "AA", "BB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB"),
sub12 = c(2, "AA", "AB", "BB", "BB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub13 = c(3, "AB", "AB", "AB", "AB", "AB", "BB", "AB", "AA", "AB", "AA", "AB", "BB"),
sub14 = c(3, "AB", "BB", "BB", "AB", "AB", "BB", "AB", "AA", "AB", "AA", "AB", "BB"),
sub15 = c(3, "AA", "AB", "BB", "BB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"))

rownames(myd) <- c("cluster", paste("var", 1:12, sep=""))

Thus this data has 15 subjects sub1 : sub15 classified by categorical variables var1: var12. The cluster id is in the first row - with row name - cluster. 
myd 
        sub1 sub2 sub3 sub4 sub5 sub6 sub7 sub8 sub9 sub10 sub11 sub12 sub13 sub14 sub15
cluster    1    1    1    1    1    1    2    2    2     2     2     2     3     3     3
var1      AB   AB   AB   AB   AB   AB   AA   AB   AA    AB    AA    AA    AB    AB    AA
var2      AB   BB   BB   BB   BB   BB   AA   AA   AA    AA    AA    AB    AB    BB    AB
var3      BB   BB   AB   AB   BB   BB   BB   AB   BB    BB    BB    BB    AB    BB    BB
var4      BB   BB   BB   BB   AB   BB   AB   AB   AB    AB    AB    BB    AB    AB    BB
var5      AA   AA   AA   AA   AB   AA   AA   AA   AA    AA    AB    AA    AB    AB    AA
var6      BB   BB   BB   BB   BB   AB   AB   AB   AB    BB    AB    AB    BB    BB    AB
var7      AB   AB   AB   AB   AB   AB   AB   AB   AB    AB    AB    AB    AB    AB    AB
var8      AA   AA   AA   AA   AA   AA   AB   AB   AB    AB    AB    AB    AA    AA    AB
var9      BB   BB   BB   BB   BB   BB   AB   AB   AB    AB    AB    AB    AB    AB    AB
var10     AB   AB   AB   AB   AB   AB   AB   AB   AB    AB    AB    AB    AA    AA    AB
var11     AA   AA   AA   AA   AA   AA   AB   AB   AB    AB    AB    AB    AB    AB    AB
var12     AB   AB   AB   AB   AB   AB   BB   BB   BB    BB    AB    BB    BB    BB    BB

I would like to see if the cluster is proper by calculating some of the measure (such as p-value) that can provide the probability that particular subject belong to certain cluster. How can I achieve this ? I do have a large number of variables / subjects, so I would need quicker solution as well. 
 A: I am not sure if you are looking for something like this.
First you can calculate distance measure and use this distance measures in several ways - one of which of-course is hierarchical cluster analysis. You can calculated distance using daisy function in package cluster. The function uses “Gower's distance” (Gower , 1971 : Biometrics 27, 857–874) for non numerical data. Back to you data:
myd <- data.frame (
 sub1 = c(1, "AB", "AB", "BB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub2 = c(1, "AB", "BB", "BB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub3 = c(1, "AB", "BB", "AB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub4 = c(1, "AB", "BB", "AB", "BB", "AA", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub5 = c(1, "AB", "BB", "BB", "AB", "AB", "BB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub6 = c(1, "AB", "BB", "BB", "BB", "AA", "AB", "AB", "AA", "BB", "AB", "AA", "AB"),
sub7 = c(2, "AA", "AA", "BB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub8 = c(2, "AB", "AA", "AB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub9 = c(2, "AA", "AA", "BB", "AB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub10 = c(2, "AB", "AA", "BB", "AB", "AA", "BB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub11 = c(2, "AA", "AA", "BB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB"),
sub12 = c(2, "AA", "AB", "BB", "BB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"),
sub13 = c(3, "AB", "AB", "AB", "AB", "AB", "BB", "AB", "AA", "AB", "AA", "AB", "BB"),
sub14 = c(3, "AB", "BB", "BB", "AB", "AB", "BB", "AB", "AA", "AB", "AA", "AB", "BB"),
sub15 = c(3, "AA", "AB", "BB", "BB", "AA", "AB", "AB", "AB", "AB", "AB", "AB", "BB"))

rownames(myd) <- c("cluster", paste("var", 1:12, sep=""))

require(cluster)
myd1 <- data.frame (t(myd[-1,]))
d <- daisy(myd1)

Here the object d distance matrix, which can be used in several ways, one of which is clustering. 
fit <- hclust(d, method="ward") 
plot(fit) # display dendogram

groups <- cutree(fit, k=3)
# draw dendogram with red borders around the 3 clusters 
rect.hclust(fit, k=3, border="red")

More attractive way to present the results is perhaps color coding creating phylogenic tree using package ape 
require(ape)
colorCodes <- c("red", "green4", "blue")
class <- as.numeric (t(myd)[,1])
plot(as.phylo(fit), tip.color=colorCodes[class], type="fan")
plot(as.phylo(fit), tip.color=colorCodes[class], type="phylogram")

You can see here that sub15 is clearly miss-classified in class 2, should be in class 3. 

