r - setRefClass pass by value, pass by reference -


I suspect that I do not understand all the aspects of setRefClass in RSS. For example, setRefClass was started I would like to create the variable X so that this variable is equal to a copy of the example, or the example of setRefClass Does. Is there a difference:

  x = instanceoffsetrphClass   

and

  x   

I am not fully able to understand and I feel that my code has strange behavior.

Thanks for your help

I do not think your problem is related to reference sections. To do anything, but to do the following, consider the following example: We start by removing all the variables from our workspace and A :

  rm = Ls ()) A = setRefClass ("A", fields = list (x = "numeric"))   

Next we create and call the function f :

  f = function () {X1 = 1 a1 = A $ new (x = 10) x2 & lt; & Lt; - 2a2 & lt; & Lt; - A $ new (x = 10)} f ()   < & lt; & Lt; - Main difference between  and  =   

operators' & lt; - & lt; - 'and' - & gt; & Gt; 'Generally used only in the work, and the present definition of parental assignment causes the discovery of being done through the parents' environment. If such a variable is found (and its binding is not locked) its value is redefined, otherwise the assignment is in the global environment.

From the help page:? & Lt; & Lt; The variable created by using = was not found in the global environment

  R> X1 error: -   Object 'x1' not found R & A; A1 Error: Object 'A1' not found   

but other variables are:

  R & gt; ; X 2 [1] 2 R & gt; A2 range "A" field references to "x" square object: [1] 10    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -