I'm trapped by what should be a simple scenario. I want to use the unique values in one column of a tibble to drive a series of subset outputs. I used 'unlist' to create a vector of "Supplier" (in this case with 28 unique values) and hope to write a loop whereby for each unique value I can return the subset from the table. Kind of like pulling apart a pivot table in excel and printing it sheet by sheet.
My data looks like this (sample only):
| Supplier | Receipt | PO | Tracking |
|---|---|---|---|
| Denco Audio Ltd | 23/02/2022 | 232960 | AAAC0002630 |
| Devonport Chocolates | 23/02/2022 | 232969 | 4519880002717001AKL001AP |
| Devonport Chocolates | 23/02/2022 | 232843 | 4519880002716901AKL001AS |
| Electric Pukeko | 23/02/2022 | 232954 | ca0006969325 |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232818 | 4603720008201401HAS011AS |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232862 | 4603720008209401HAM006AS |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232818 | 4603720008201401HAS011AS |
| Glen Dimplex New Zealand Ltd | 24/02/2022 | 232952 | 4603720008236101AKL006AS |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232876 | 4603720008209301AKL006AS |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232775 | 4603720008202602CHC016BS |
| Glen Dimplex New Zealand Ltd | 23/02/2022 | 232775 | 4603720008202602CHC016BS |
So I should be able to get a subset for Denco, Devonport Chocolates, etc and print it to file.
Excel output 1:
| Supplier | Receipt | PO | Tracking |
|---|---|---|---|
| Denco Audio Ltd | 23/02/2022 | 232960 | AAAC0002630 |
Excel output 2:
| Supplier | Receipt | PO | Tracking |
|---|---|---|---|
| Devonport Chocolates | 23/02/2022 | 232969 | 4519880002717001AKL001AP |
| Devonport Chocolates | 23/02/2022 | 232843 | 4519880002716901AKL001AS |