Suppose, we have 3 people called: Francis, Cedric and Nina. Base on what they have eaten, we want to cluster people by "diet", "non-diet". # original data file, named as filename "food.csv". Francis|potato Francis|chocolate Francis|chocolate Francis|milk Cedric|vegetable Cedric|vegetable Cedric|potato Nina|potato Nina|chocolate Nina|chocolate Nina|potato # Step 1: I plan to reform the food.csv file into following frame: Francis Cedric Nina potato 1 1 2 chocolate 2 0 2 milk 1 0 0 0 fish 0 1 0 0 vegetable 0 2 0 But, I have problem to reform the original file into that way I want. Basically, I have only tried:> org<-read.table("food.csv",col.name=c("name","food_list"), sep="|") #import file to R> x<-data.frame(Francis=rep(0,times=5)) # set up the frame of file > rownames(x)<-org$food_listhere I failed, and don't know how to continue. Please help me out with the proper R command. # Step 2: I want to draw 3 overlapped barplot with x-axis(5 food name list), y-axis(the occurence value of each food by each person). # Step 3: By comparing the barplots, I should be able to draw the conclusion: Francis and Nina are in the group of "non-diet", and Cedric is in the group of "diet". Well, that's my simple strategy of "clustering", if any of you have better suggestion, I really appreciate it. Thanks! [[alternative HTML version deleted]]