How could I make "function_2" in R properly? If any of you have any idea? I wanted to use the jitter function, but I am not sure if this may work or not.
You could use a different distribution to get random noise from if you wanted to, using the appropriate r[distribution-shorthand]() function instead of rnorm(), or change the mean and sd arguments to be something else, or control them with arguments to your function, too.
This is also assuming your var values are all length 1 (as opposed to vectors), if you're working with vectors you could add the normals afterwards, using the length of output to add a different amount of noise to each value: