[R] memory management, scale

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Tue May 21 10:45:23 CEST 2002


On Tue, 21 May 2002, Kolling Alfons, F+E wrote:

>
>
> Hi experts,
>
> 1.  I am working with large datasets (80000 rows, 20 columns) with R 1.3.0
> und linux; so i try to save memory and remove unused objects. But even if i
> remove all objects with rm() and force the garbage collector to work with
> gc(), the process monitor utiliity kpm does not show a change of a single
> byte in memory consumption. So what is wrong.

Memory allocators often do not return memory to the OS when it is freed,
but it remains allocated to the process and available for re-use by
malloc.  (On the other hand, RH Linux does seem to be one of the
exceptions.)  Also R does not return its workspace to the memory
allocator when it removes unused objects unless they were large enough to
have been allocated individually.

gc() will give a better idea of the actual usage that utilities such as
top.


> 2. I order to scale a second dataset within a regression model created with
> a first scaled data setm i would like to scale the second data set in the
> same way like the first one, but i cannot find the shift and factor of the
> first scale (for example with attributes or methods). Are the shift and
> offset stored anywhere or not? (I know, i can calculate the desired values
> with mean and root mean square; but when doing that, why should i use scale
> at all?)

That's pretty unclear.  If you mean you did

data2 <- scale(data1)

then the answer is that the scaling is stored in attributes:

> library(MASS)
> data(hills)
> hills2 <- scale(hills)
> attributes(hills2)
...
$"scaled:center"
       dist       climb        time
   7.528571 1815.314286   57.875714

$"scaled:scale"
       dist       climb        time
   5.523936 1619.150536   50.040716

*and* that is stated on the help page.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list