binary - How to transform data into suitable table for calculating single linkage clustering in R -


i'm trying transform data data table binary code (for clustering later on). data i've got looks this:

  order_number  product_id              34       37552               5       24852              10       24852              15       33290               7       23586              35       22395               4       16766              33       46393               9       12916              61       12341  

what want column order_number row header , paste 0 or 1 depending on whether product product_id in order_number cell or not. order_number should basket. i'd similar this:

                  order_number   product_id    34              5       37552          1              0       24852          0              1        24852          0              1     

does know how it? highly appreciated, i'm stuck.

how simple table?

> table(df$product_id, df$order_number, dnn=c("product id","order number"))  ##           order number ## product id 4 5 7 9 10 15 33 34 35 61 ##      12341 0 0 0 0  0  0  0  0  0  1 ##      12916 0 0 0 1  0  0  0  0  0  0 ##      16766 1 0 0 0  0  0  0  0  0  0 ##      22395 0 0 0 0  0  0  0  0  1  0 ##      23586 0 0 1 0  0  0  0  0  0  0 ##      24852 0 1 0 0  1  0  0  0  0  0 ##      33290 0 0 0 0  0  1  0  0  0  0 ##      37552 0 0 0 0  0  0  0  1  0  0 ##      46393 0 0 0 0  0  0  1  0  0  0 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -