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

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed May 26 20:40:46 CEST 2010


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:

711659926691456588820198688981513283237719214167524272940980007340737850\
071505550367426050190853744948955339987662427844810850852717191846883823768674\
280839119270574786535774460628640384757837267418932039347078114901615267344319\
690975277428929737916031623809028545597238524149983532303848529517503894555603\
085813572927495336324076794731576794044444062823255544802787912646756996122962\
654809395519130134923611540639384237080197541181260772381917961683956924416

 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



More information about the R-help mailing list