[R] WriteXLS error:Error in get(x, envir = envir) : variable names are limited to 256 bytes

Marc Schwartz marc_schwartz at me.com
Sat Dec 11 06:57:14 CET 2010

On Dec 10, 2010, at 4:14 PM, David Winsemius wrote:

> On Dec 10, 2010, at 5:02 PM, David Winsemius wrote:
>> On Dec 10, 2010, at 4:39 PM, Patrick McKann wrote:
>>> Hello all,
>>> I don't understand why this won't work.  I have entered:
>>> WriteXLS(alldata,'test.xls')
>> I have gotten tripped up by the argument syntax in WriteXLS myself, many times. Please check the help page for argument names and use them, especially paying attention to the fact that the first argument needs to be a character _vector_ (and I suspect that passing it a list may not qualify) and I always use the name for the Excel file argument. I suspect that this may work:
>> WriteXLS('alldata','test.xls')
> OOOPs. I wrote that before I noted that you said you were using a list, and I forgot to go back and fix it, so that would NOT work.
>> -- 
>> David.
>>> and I get this error message:
>>> Error in get(x, envir = envir) : variable names are limited to 256 bytes.
>>> My variable names are not very long, and are accepted by write.csv.
>>> alldata is a list containing 4 dataframes, with each dataframe having the
>>> the same variable names, which are:
>>>> names(avg8302)
>>> [1] "ID"            "cluster"       "rec.unit"      "int.hib"
>>> "yr.hib"        "yr0309.hib"    "int.hib.se"    "yr.hib.se"     "
>>> yr0309.hib.se" "int.cl"
>>> [11] "yr.cl"         "yr0309.cl"     "int.cl.se"     "yr.cl.se"      "
>>> yr0309.cl.se"  "int.ru"        "yr.ru"         "yr0309.ru"     "int.ru.se"
>>> "yr.ru.se"
>>> [21] "yr0309.ru.se"  "int.sp"        "yr.sp"         "yr0309.sp"     "
>>> int.sp.se"     "yr.sp.se"      "yr0309.sp.se"
>>> Does anybody know how I can fix this?  Or another way to write a multi-sheet
>>> xls?
>>> Thank you.

Hi David and Patrick,

Apologies for the delay in my reply as I am away on vacation at the moment.

As David surmised initially, the name of the object(s) to be exported, needs to be passed as a character vector. The vector can either contain the names of one or more data frames, or can be the single name of a list of data frames. The latter option was added in a September update. See the help page for an example of use.


  WriteXLS("alldata", "test.xls")

should work.


Marc Schwartz

More information about the R-help mailing list