I am new to R and struggling with it a bit. I have a data frame like this
reg 12345
val1 1
val2 0
reg 45678
val1 0
val2 0
val3 1
reg 97654
val1 1
reg 567834
val3 1
reg 567845
val2 0
val4 1
My goal is to transform data into this format into
reg val1 val2 val3 val4
12345 1 0 0 0
45678 0 0 1 0
97654 1 0 0 0
567834 0 0 1 0
567845 0 0 0 1
Hoping somebody can guide me here. My data source is less than 200 lines and there are no constraints with regards to the approach. Please assume that the machine running had adequate memory and processing power.