I would like to divide my dataframe into multiple csv files by group "Rkey". For example, the sample data below would result in 3 different csv files being made, one for each unique Rkey group: R01, R02, and R03. Each of the three files would only include the rows belonging to its respective group. The names of these files can match the Rkey group name.
How should I work this out? many thanks!
Pkey Rkey Var1 Var 2
R01_1 R01 0.0000861 0.0021976
R01_2 R01 0.0157098 0.0415425
R01_3 R01 0.0142236 0.0316527
R01_4 R01 0.0000328 0.3496403
R01_5 R01 0.0122406 0.1739126
R02_1 R02 0.0000856 0.0000915
R02_2 R02 0.0002946 0.0006898
R02_3 R02 0.0209878 0.0209901
R02_4 R02 0.0001359 0.0008970
R02_5 R02 0.0011158 0.0023558
R02_10 R02 0.0015220 0.0019581
R02_11 R02 0.0004664 0.0385724
R02_12 R02 0.0000095 0.3224465
R03_1 R03 0.0008863 0.0056300
R03_2 R03 0.0000021 0.0000185
R03_3 R03 0.0000170 0.0001655