[R] error "variable names are limited to 256 bytes" when sou

(Ted Harding) Ted.Harding at manchester.ac.uk
Wed May 26 21:12:33 CEST 2010


On 26-May-10 18:40:46, Barry Rowlingson wrote:
> On Wed, May 26, 2010 at 6:00 PM, Wu Gong <ghowoo at gmail.com> wrote:
>>
>> I can only repeat your error message :)
>>
>>> n256 <- paste(rep("A",256),collapse="")
>>> assign(n256, 1)
>>> n257 <- paste(rep("A",257),collapse="")
>>> assign(n257, 1)
>> Error in assign(n257, 1) : variable names are limited to 256 bytes
> 
>  If a variable name can have 26 upper case + 26 lower case + 10
> numbers then the number of possible variable names is:
> 
> 711659926691456588820198688981513283237719214167524272940980\
> 007340737850071505550367426050190853744948955339987662427844\
> 810850852717191846883823768674280839119270574786535774460628\
> 640384757837267418932039347078114901615267344319690975277428\
> 929737916031623809028545597238524149983532303848529517503894\
> 555603085813572927495336324076794731576794044444062823255544\
> 802787912646756996122962654809395519130134923611540639384237\
> 080197541181260772381917961683956924416
> 
> which should be enough for everyone (that's probably a lower
> bound since names can have dots and underscores etc in them).
> 
> I suspect the code is doing something very horrible with variable
> names, and needs to be restructured to use lists or vectors or
> arrays or anything other than encoding information into the
> name of an object.
> 
> I had to calculate 62^256 in Maxima since R thinks it's infinite.
> Barry

Barry,
Add in a couple of extras to the domain, for the "." and "_", and
you get 64^256 = (2^6)^256 = 2^1536, which is easier to grasp.

And I wouldn't bother with maxima myself -- bc will do:

$ bc -l
[banner stuff]
2^1536
241031242692103258858011660602831411291209324794568895135967\
503906525739159180320066908502410734604966344876628088800478\
786241697879495832496961298789077465145521333938162522477078\
207791768149967684554313738782005759734585790459910946138712\
209950796499781564134230067762947335528161742841179416396778\
587037036896910922159194305423201156275845008057958785090099\
371489228347664663118151506380487337518226050624699283789870\
5971012525843324401232986857004760339316736

or, less precisely, 10 to the power:

scale=200
l(2^1536)/l(10)
462.38207333987511584830294229682128911593965792579871945281\
658029123817872551604657192025925353396025449135696603800890\
228956346542109210521552742457041240329907655309444106648855\
511190262212121781847591

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 26-May-10                                       Time: 20:12:29
------------------------------ XFMail ------------------------------



More information about the R-help mailing list