How to handle a custom function that returns a short list

I am attempting to run a custom script that uses a column as input and returns a list that is shorter than the number of rows. For example when I attempt to use with “mutate” i get the error message “Error : Column calculation_1 must be length 3426 (the number of rows) or one, not 16”.

The 16 items returned are indexes to local maxima and I don’t have a straight forward way to pad the result to the length of the dataframe.

No doubt my challenge is to being a relative newbie to R but any suggestion appreciated.