On 3/15/11 8:28 PM, Brent Pedersen wrote: > system info below. > maybe it's internal to R: > > >> a = 1:199999999 >> sum(a) > [1] NA > Warning message: > In sum(a) : Integer overflow - use sum(as.numeric(.)) >> sum(as.numeric(a)) > Error: cannot allocate vector of size 1.5 Gb
This is a limitation/characteristic of R, somehow. Integers are C-int while in Python they are C-long in Python >= 3, C-int/C-long in Python < 3 (I am not sure about where Python 2.7 stands). Where Python < 3 would silently upgrade an int to a long, R's sum throws an overflow error. > > > but this works in a new session: > >> a = vector(length=199999999, mode="numeric") >> sum(a) > [1] 0 You are requiring less RAM because you do not have to hold two long vectors in memory at the same time. as.numeric() does make a copy. > > > ############################################### > > import numpy numpy.__version__ ? > Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) > [GCC 4.4.5] on linux2 > > R version 2.12.1 (2010-12-16) > Copyright (C) 2010 The R Foundation for Statistical Computing > ISBN 3-900051-07-0 > > Linux latitude 2.6.35-27-generic-pae #48-Ubuntu SMP Tue Feb 22 > 21:46:58 UTC 2011 i686 GNU/Linux > > $ hg branch; hg identify > version_2.2.x > 97d788ba27f8+ (version_2.2.x) tip Good. Eventual fixes would appear there first. > > On Tue, Mar 15, 2011 at 1:03 PM, Laurent Gautier<lgaut...@gmail.com> wrote: >> On 3/15/11 5:45 PM, Brent Pedersen wrote: >>> >>> On Tue, Mar 15, 2011 at 9:40 AM, Laurent Gautier<lgaut...@gmail.com> >>> wrote: >>>> >>>> It can do either one of the two. >>>> >>>> >>>> http://rpy.sourceforge.net/rpy2/doc-dev/html/numpy.html?#low-level-interface >>>> >>>> >>>> >>>> L. >>>> >>> >>> how about in this case?:: >>> >>> >>> import numpy as np >>> import rpy2.robjects as robjects >>> import rpy2.robjects.numpy2ri >>> R = robjects.r >>> >>> a = np.arange(199999999) >>> R.sum(a) >>> >>> it seems to always make a copy, even if i have it in column order. >> >> It shouldn't be the case, I think. Any details about the Python/numpy/rpy2 >> versions ? >> >> ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list