Skip to content
Prev 306690 / 398506 Next

Transform pairwise observations into a table

Hello,

Try the following.


dat <- read.table(text="
ind1 ind2 coef
1 1 1
1 2 0.25
1 3 0.125
1 4 0.5
2 2 1
2 1 0.25
2 3 0.125
2 4 0.5
3 3 1
3 1 0.125
3 2 0.125
3 4 0.5
4 4 1
4 1 0.5
4 2 0.5
4 3 0.5
", header=TRUE)
dat

reshape(dat, v.names = "coef", idvar = "ind1", timevar = "ind2",
         direction = "wide")

Hope this helps,

Rui Barradas
Em 01-10-2012 17:17, AHJ escreveu: