[R] formating for dist function

2006-08-05 Thread Ffenics
Hi there I have a list that looks like this object1 object1 78 object1 object2 45 object1 object3 34 object1 object4 45 object2 object2 89 object2 object3 32 object2 object4 13 but i want to create a matrix like this in order to use the dist function of R object1 object2

Re: [R] formating for dist function

2006-08-05 Thread Gabor Grothendieck
Here are three ways: # read in data Lines - object1 object1 78 object1 object2 45 object1 object3 34 object1 object4 45 object2 object2 89 object2 object3 32 object2 object4 13 DF - read.table(textConnection(Lines)) # 1 - xtabs xt - as.matrix(xtabs(V3 ~., DF)) # 2 - reshape wide - reshape(DF,