How do I subset lists based on multiple conditions as outlined below

Hi everyone. I have a (sample) dataset containing stores and the (fruits) inventory that they are holding. Is it possible to subset by randomly selecting x number of items based on a criteria. Here is an example: Select list of 3 mangos and 4 bananas with unique SKUs for store A & C. I have attached the sample data. In real world I have about 30K observations and would like to subset about 100 observations for over 50 stores.

What have you tried so far? Any code would be appreciated.

A screenshot of the data is basically useless. A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with. though this might not be enough in your situation.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.