This Article Contains information directly from the Pikmin Games. This article is based off of an Enemy/Treasure/Area/Cave/Pikmin/Character from the Pikmin series of Games.
When a Red Pikmin carries a pellet or enemy, it brings it to the Red Onion. Yellow Pikmin take them to the Yellow Onion, and Blue Pikmin to the Blue Onion. Purple or White Pikmin will choose an Onion randomly. However, if mixed colors carry them, it gets more complicated.
If a mixture of any of the "primary" Pikmin (red, yellow and blue) carries an object, it will go to the Onion color which makes up the majority of carriers. If the numbers of each color carrying it is equal, or there are, say, an equal amount of Blues and Yellows and fewer Reds than either of those, the Onion is chosen randomly from the equal colors. This also applies where the only Pikmin carrying the item are white or purple.
If any Purple or White Pikmin are carrying with a primary-colored Pikmin, they will simply be ignored since they have no Onions of their own, and the above rules will apply. For example, if 99 whites and one red are carrying the item, it will still be brought to the Red Onion, since the White Pikmin are ignored.