R: report data from dataframe in other way -


i have question generating dataframe out of dataframe. new dataframe contains same information old dataframe reported data in other way. dataframe start with, looks this:

> gene.symbol      mirna     nap1l1       mmu-let-7a     napepld      mmu-let-7b     nat8l        mmu-let-7b     nceh1        mmu-let-7b     ncoa3        mmu-let-7a     ndst2        mmu-let-7a     ndst3        mmu-let-7a     nedd4l       mmu-let-7a     nedd4l       mmu-let-7b     nefm         mmu-let-7a 

now want convert dataframe dataframe below.

>b               mmu-let-7a    mmu-let-7b     nap1l1       1             0      napepld      0             1     nat8l        0             1     nceh1        0             1     ncoa3        1             0     ndst2        1             0     ndst3        1             0     nedd4l       1             1     nefm         1             0 

can me this? many thanks! regards lisanne

using reshape2:

require(reshape2) df$z <- 1 dcast(df, gene.symbol ~ mirna, value.var="z", fill=0) #   gene.symbol mmu-let-7a mmu-let-7b # 1      nap1l1          1          0 # 2     napepld          0          1 # 3       nat8l          0          1 # 4       nceh1          0          1 # 5       ncoa3          1          0 # 6       ndst2          1          0 # 7       ndst3          1          0 # 8      nedd4l          1          1 # 9        nefm          1          0 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -