Say I have a matlab function:
function y = myfunc(x)
persistent a
a = x*10
...
What is the equivalent statement in R for the persistent a statement? <<- or assign()?
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.
Here’s one way:
What happens is that
localcreates a new environment around thex<-NULLand the function declaration. So inside the function, it can get to thexvariable and assign to it using<<-.You can find the environment for a function like this: