Function for spreading different values

Hi there,

I'm looking for a function that allows me to distribute a value over several cells based on an U-shaped model.
For example if that value is 100 and I have 9 cells I need to assign 40% to the first cell, 40% to the last cell and the remaining 20% spread evenly between the 2nd and 8th cell.

Also, the number of cells vary for every value. For instance another value of 300 might need to be spread over 5 cells.

Hope it makes sense.
Many Thanks


Have you already tried something ? What issue are you encountering ?
Even if it does not work you can share what you tried so far.


Hello, I was hoping to get some pointers/tips here as my R is still pretty basic.