I think I need the mapply rather than the lapply function in what I was trying to do.
mapply
lapply
This is the function that I have in mind - not working yet