R Help converting factor data from long to wide and assigning logical value
问题 I have data in long format as seen below: Data: id code 1 EP 2 EP 3 EP 4 UM 5 UM 1 UM 2 UM 10 UM 6 BZ 7 BZ 14 BZ 2 BZ 8 TVOL 9 TVOL 16 TVOL 10 NW 11 NW 7 NW 12 SM 13 SM 3 SM 14 GS 15 GS 1 GS 2 GS 9 GS I would like to create a wide dataframe with each "code" as its own column marked TRUE/FALSE depending on whether there's an associated "id" as seen in the minimal example below: id code.EP code.UM code.BZ code.TVOL code.NW code.SM code.GS 1 TRUE TRUE FALSE FALSE FALSE FALSE TRUE 2 TRUE FALSE