How to return local variable value from a function written in R using spark.lapply()

I have defined some functions written in the R Language... Now I am trying to use " spark.lapply " to parallelize the function. So exactly what happening is I am defining one empty vector inside the function and values are getting populated inside the function.

So, if I am calling the vector later in code after calling the function using spark.lapply(), I am getting the error " Object Not Found ".