Skip to content

persistant: Matlab->R

4 messages · Bernard Gregory, Charles Annis, P.E., Roy Mendelssohn - NOAA Federal +1 more

#
It might be helpful to those not familiar with Matlab to tell us what
function "persistent" does.

Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Bernard Gregory
Sent: Thursday, December 14, 2006 1:14 PM
To: r-help at stat.math.ethz.ch
Subject: [R] persistant: Matlab->R

Dear list members,

Could anyone tell me if there is an equivalent of the Matlab declaration
'persistant' in R?

Thank you very much,

Bernard Gregorry.
(Matlaber converted to R).

 		
---------------------------------


______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
At 3:10 PM -0500 12/14/06, Charles Annis, P.E. wrote:
Independent response  (I was not the original  poster)

  help persistent
  PERSISTENT Define persistent variable.
     PERSISTENT X Y Z defines X, Y, and Z as variables that are local
     to the function in which they are declared yet their values are
     retained in memory between calls to the function.  Persistent
     variables are similar to global variables because MATLAB creates
     permanent storage for both.  They differ from global variables in
     that persistent variables are known only to the function in which
     they are declared.  This prevents persistent variables from being
     changed by other functions or from the MATLAB command line.

     Persistent variables are cleared when the M-file is cleared from
     memory or when the M-file is changed.  To keep an M-file in memory
     until MATLAB quits, use MLOCK.

     If the persistent variable does not exist the first time you issue
     the PERSISTENT statement, it will be initialized to the empty matrix.

     It is an error to declare a variable persistent if a variable with
     the same name exists in the current workspace.

     See also global, clear, mlock, munlock, mislocked.


     Reference page in Help browser
        doc persistent
#
It is just my guess that the 'open.account' example in 10.7 Scope of 
Introduciton to R is what you are after.

If I understand what 'presistent' means, the 'total' in the example is 
approximately equal to a persistent variable.
On Thu, 14 Dec 2006, Bernard Gregory wrote:

            
Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0717