简体   繁体   中英

Exporting data.frame to .xls(x) R error

I'm using CRAN package WriteXLS to export a data.frame from R to an excel sheet. My target data frame is made up 33988 observations of 9 variables. When I try to export that data.frame I get this error.

> WriteXLS(mydata,ExcelFileName='R.xlsx')
Error in get(x, envir = envir) : 
  variable names are limited to 10000 bytes

The variable names for my data are 'schoolid', 'caseid', 'score', 'cohort90' etc so I don't understand the error or how to resolve it. My first attempt was to create a simpler data.frame and try to export that.

> get('xy')
   x y
1  0 1
2  9 2
3  8 3
4  7 4
5  6 5
6  5 6
7  4 7
8  3 8
9  2 9
10 1 0
> WriteXLS(xy,ExcelFileName='R.xlsx')
Error in get(x, envir = envir) : 
  object 'c(0, 9, 8, 7, 6, 5, 4, 3, 2, 1)' not found

So it's a different error message, but I still don't understand why the error is happening since I was able to get(xy) just prior to executing the WriteXLS command.

I have all the required support for the package

> testPerl()
Perl found.

All required Perl modules were found.

WriteXLS is expecting the name of your data.frame, not the data.frame itself

From ?WriteXLS

x: A character vector containing either the names of one or more R data frames, or the single name of a list containing one or more R data frames, to be exported to the Excel file

Try: WriteXLS("mydata", ExcelFileName="R.xlsx")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM