I have data-frame with three columns:
| Sample | Gene-name | FPKM |
|---|---|---|
| A1 | BRCA1 | 2.0 |
| B1 | LATS1 | 3.4 |
| C1 | WWTR | 4.6 |
| D1 | FAT1 | 5.2 |
My desired format is:
| BRCA | LATS1 | WWTR | FAT1 | |
|---|---|---|---|---|
| A1 | 2.0 | 0 | 0 | 0. |
| B1 | 0 | 3.4 | 0 | 0 |
| C1 | 0 | 0 | 4.6 | 0 |
| D1 | 0 | 0 | 0 | 5.2 |
I used the following code: Reshaping<-X_df %>% dcast(sample~Gene-name,value.var = "FPKM",fun.aggregate = NULL).
But its throwing an error: Aggregation function missing: defaulting to length
And I am getting an output in a wide-format but the values are just 1. Where are the FPKM values going? what am I doing wrong?