library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.1.3
library(ca)
## Warning: package 'ca' was built under R version 3.1.3
#create data
lok=sample(c("Cileunyi","UB","Antapani","Dago"),40,replace=TRUE)
jenis=sample(c("Toko","Rumah","Kantor","Ruko"),40,replace=TRUE)
sebab=sample(c("Elektrik","Gas","Kompor","Bom"),40,replace=TRUE)

custid=sample(1:100,40,replace=FALSE)
freq=sample(1:200,40,replace=TRUE)
data1=as.data.frame(cbind(lok,jenis,sebab))



#########caOK##################################
mca41 = mjca(data1,lambda = "indicator", nd = 5)
cats1 = apply(data1, 2, function(x) nlevels(as.factor(x)))
cats1
##   lok jenis sebab 
##     4     4     4
mca4_vars_df1 = data.frame(mca41$colcoord, Variable = rep(names(cats1), 
    cats1))

mca41$levelnames <- gsub("lok","",mca41$levelnames)
mca41$levelnames <- gsub("jenis","",mca41$levelnames)
mca41$levelnames <- gsub("sebab","",mca41$levelnames)





rownames(mca4_vars_df1) = mca41$levelnames


# plot of variable categories
ggplot(data = mca4_vars_df1, aes(x = X1, y = X2, label = rownames(mca4_vars_df1))) + 
    geom_hline(yintercept = 0, colour = "gray70") + geom_vline(xintercept = 0, 
    colour = "gray70") + geom_text(aes(colour = Variable)) + ggtitle("MCA")+labs(colour="Response")+theme_bw()

###############################################
library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 3.1.3
kec=LETTERS[seq( from = 1, to = 26 )]

#create data
x1=sample(1:5,26,replace=TRUE)
x2=sample(1:4,26,replace=TRUE)
x3=sample(1:3,26,replace=TRUE)
data1=as.data.frame(cbind(x1,x2,x3))
data1$x1=as.numeric(data1$x1)
data1$x2=as.numeric(data1$x2)
data1$x3=as.numeric(data1$x3)


rownames(data1)=kec
res.pca <- PCA(data1)

res.hcpc <- HCPC(res.pca, nb.clust=0, conso=0, min=3, max=10)

res.hcpc
## **Results for the Hierarchical Clustering on Principal Components**
##    name                   
## 1  "$data.clust"          
## 2  "$desc.var"            
## 3  "$desc.var$quanti.var" 
## 4  "$desc.var$quanti"     
## 5  "$desc.axes"           
## 6  "$desc.axes$quanti.var"
## 7  "$desc.axes$quanti"    
## 8  "$desc.ind"            
## 9  "$desc.ind$para"       
## 10 "$desc.ind$dist"       
## 11 "$call"                
## 12 "$call$t"              
##    description                                             
## 1  "dataset with the cluster of the individuals"           
## 2  "description of the clusters by the variables"          
## 3  "description of the cluster var. by the continuous var."
## 4  "description of the clusters by the continuous var."    
## 5  "description of the clusters by the dimensions"         
## 6  "description of the cluster var. by the axes"           
## 7  "description of the clusters by the axes"               
## 8  "description of the clusters by the individuals"        
## 9  "parangons of each clusters"                            
## 10 "specific individuals"                                  
## 11 "summary statistics"                                    
## 12 "description of the tree"
Motion=gvisMotionChart(Fruits, 
                       idvar="Fruit", 
                       timevar="Year")
print(Motion,'chart')
#plot(Motion)
#options(op)
#print(sc, 'chart') ## same as cat(sc$html$chart)