I have a scenario where I need to present a consistent table of data, refreshed frequently.
My source data may look like:
Item | Quantity
-------------------
Dog | 2
Cat | 1
Apple | 6
Banana | 2
Kiwi | 4
I only require a few items from my source, which may or may not appear. Currently I'm using subset to select the items of interest:
groceries <- subset(data, item == "Apple" |
item == "Orange" |
item == "Banana" |
item == "Kiwi"
)
Which results in:
Item | Quantity
-------------------
Apple | 6
Banana | 2
Kiwi | 4
However, I need include blank rows for those items that arnt included in the source, so that my table is consistent between refreshes:
Item | Quantity
-------------------
Apple | 6
Orange |
Banana | 2
Kiwi | 4
Is anyone able to guide me how best to approach the above, please?