[R-es] ¿Pasar parámetros por referencia?

Carlos J. Gil Bellosta cgb en datanalytics.com
Mie Sep 28 16:48:48 CEST 2011


Seguramente la respuesta es negativa, pero... ¿realmente necesitas
toda la matriz cargada a la vez? ¿No puedes procesarla por bloques,
por columnas, de alguna otra manera que no implique tenerla entera en
memoria?

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com


El día 28 de septiembre de 2011 16:36, Servicio de Estadísticas
Demográficas y Sociales <seds.ive en gmail.com> escribió:
> Lo estoy corriendo en
>
> Operating system: Redhat Enterprise Linux 6
>
> Kernel and CPU: Linux 2.6.32-131.6.1.el6.x86_64 on x86_64
>
> Processor information: Intel(R) Xeon(TM) CPU 3.60GHz, 4 cores
>
> Memory: 8 GB (supongo que aquí está el problema)
>
> Un saludo.
> Seds
>
> El 28 de septiembre de 2011 16:26, Carlos Ortega <coforfe en gmail.com>escribió:
>
>> Hola,
>>
>> No sé si utilizas R sobre una máquina Windows.
>> Si es así, una alternativa adicional es utilizar la solución "hardware"
>> además de correr sobre 64-bits:
>>
>>  2.28 Should I run 32-bit or 64-bit R?
>>
>> For most users (especially beginners) we would recommend using the 32-bit
>> build.
>>
>> The advantage of a native 64-bit application is that it gets a 64-bit
>> address space and hence can address far more than 4GB (how much depends on
>> the version of Windows, but in principle 8TB). This allows a single process
>> to take advantage of more than 4GB of RAM (if available) and for R's memory
>> manager to more easily handle large objects (in particular those of 1GB or
>> more). The disadvantages are that all the pointers are 8 rather than 4 bytes
>> and so small objects are larger and more data has to be moved around, and
>> that less external software is available for 64-bit versions of the OS. The
>> 64-bit compilers are able to take advantage of extra features of all x86-64
>> chips (more registers, SSE2/3 instructions, ...) and so the code may run
>> faster despite using larger pointers.
>>
>> For advanced users the choice may be dictated by whether the contributed
>> packages needed are available in 64-bit builds (and if CRAN binary packages
>> are not that is some indication that installing them from sources is
>> problematic). At the time of writing the most commonly-used CRAN packages
>> without 64-bit versions were BRugs and rggobi. The considerations can be
>> more complex: for example 32/64-bit RODBC need 32/64-bit ODBC drivers
>> respectively, and where both exist they may not be able to be installed
>> together. An extreme example is the Microsoft Access/Excel ODBC drivers: if
>> you have installed 64-bit Microsoft Office you can only install the 64-bit
>> drivers and so need to use 64-bit RODBC and hence R.
>>
>>
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>>
>>
>> 2011/9/28 Servicio de Estadísticas Demográficas y Sociales <
>> seds.ive en gmail.com>
>>
>>> Lo primero, muchas gracias por tus sugerencias. Voy a investigar el
>>> paquete
>>> ff a ver si así lo resuelvo.
>>>
>>> Sobre la segunda alternativa que apuntas, ¿puede modificarse parte de una
>>> matriz mediante assign o alguna función similar?
>>>
>>> Saludos.
>>> Seds
>>>
>>> El 28 de septiembre de 2011 14:17, Ramon Diaz-Uriarte
>>> <rdiaz02 en gmail.com>escribió:
>>>
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, 28 Sep 2011 13:53:19 +0200,Servicio de Estadísticas Demográficas
>>> y
>>> > Sociales <seds.ive en gmail.com> wrote:
>>> > > [1  <text/plain (quoted-printable)>]
>>> > > ¿Hay alguna manera de pasar a parámetros por referencia?
>>> >
>>> > > El problema es que tengo una matriz muy grande (unos 6 Gb) que al
>>> pasarla
>>> > > como parámetro a una función (que, además debe modificarla) R
>>> > internamente
>>> > > trata de copiarla y se genera un error de "imposible ubicar un vector
>>> de
>>> > 6
>>> > > Gb)
>>> >
>>> >
>>> > Hay varios paquetes en CRAN que implementan diversas formas de acceso
>>> por
>>> > referencia. Pero, en tu caso, quizás el paquete "ff" (que deja las cosas
>>> > en disco, y accede sólo ---pero de forma muy rápida--- a lo necesario)
>>> te
>>> > sea más útil.
>>> >
>>> > > Aunque sé que no es buena práctica, también me valdría si pudieran
>>> > definirse
>>> > > variables "globales".
>>> >
>>> >
>>> > Puedes imitar parcialmente el comportamiento de variables globales
>>> usando
>>> > las reglas del scope, si no redefines la variable en el conjunto de
>>> > environments anidados, y si no la pasas como parámetro de tu función. Y
>>> > pudes cambiar esas variables globales con assign, y similares.
>>> >
>>> >
>>> > Pero generalmente suele dar lugar a código difícil de mantener y
>>> debuggear.
>>> >
>>> > Un saludo,
>>> >
>>> >
>>> > R.
>>> >
>>> >
>>> > > Un saludo.
>>> > > Seds
>>> >
>>> > >       [[alternative HTML version deleted]]
>>> >
>>> > > [2  <text/plain; iso-8859-1 (quoted-printable)>]
>>> > > _______________________________________________
>>> > > R-help-es mailing list
>>> > > R-help-es en r-project.org
>>> > > https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> > --
>>> > Ramon Diaz-Uriarte
>>> > Department of Biochemistry
>>> > Universidad Autónoma de Madrid
>>> > Spain
>>> >
>>> > http://ligarto.org/rdiaz
>>> >
>>> > Temporarily at:
>>> > Structural Biology and Biocomputing Programme
>>> > Spanish National Cancer Centre (CNIO)
>>> >
>>> > Phone: +34-91-732-8000 ext. 3019
>>> > Fax: +-34-91-224-6972
>>> >
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>>
>>>
>>> _______________________________________________
>>> R-help-es mailing list
>>> R-help-es en r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>>
>>>
>>
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-help-es mailing list
> R-help-es en r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>



Más información sobre la lista de distribución R-help-es