Transform counts to binary variable in DataFrame

One more approach, inspired by this post:

v1 = vcat(fill.(df1.subject, df1.count)...)
v2 = vcat(fill.(df1.response, df1.count)...) .== "yes"
df2 = DataFrame(subject = v1, y = Int64.(v2))

5×2 DataFrame
 Row │ subject  y     
     │ Int64    Int64 
─────┼────────────────
   1 │       1      1
   2 │       1      1
   3 │       2      1
   4 │       2      1
   5 │       2      0
1 Like