how to pass data between functions in r