I understand that variables are local to a function in R, but what happens if I recursively call a function from itself? Will assignments from within the function be overwritten by subsequent evocations of the function?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In typical programming languages, variables created in a function are local to that function. A function calling itself is similar to a function calling another function, as far as the variables created and housed within that function. Soon as that function returns the variables and their association in memory are lost; and unless you use pointers, references, returning variables, etc. you will not be able to retrieve this information, regardless if it’s a recursive function.
I am not sure about R in specific, but I would simply create a simple test to see.