Following this previous question: Add 0 or 1 in a df depending on conditions from another df
I have now a similar purpose but a bit different. I have df1
but with a third column "value":
file_name loc num
rep1 chr1:62161618:62162663:- 3
rep2 chr1:62161618:62162669:- 5
...
I would like to generate a df2
matrix with file_name
as rows and loc
as columns. Finally I want to fill the matrix df2
with the values from num
and 0 for the rest, something like:
chr1:62161618:62162663:- chr1:62161618:62162669:-...
rep1 3 0
rep2 0 5
...
Thanks!