If I have a data.frame
df <- data.frame(DEP=letters[1:5], ARR=letters[11:15], NO=1:5+5) DEP ARR NO 1 a k 6 2 b l 7 3 c m 8 4 d n
?xtabs:
?xtabs
xtabs(NO ~ ., data=df) # ARR #DEP k l m n o # a 6 0 0 0 0 # b 0 7 0 0 0 # c 0 0 8 0 0 # d 0 0 0 9 0 # e 0 0 0 0 10