createSheet error xlsx llibrary

2019-09-16 09:49发布

问题:

I am using the xlsx package in R to create a new Excel workbook and then create a new Excel sheet in that workbook to send data to. When I ran my code last there were no issues. Now when I run it I get the following error: Error in as.vector(x, "character") : cannot coerce type 'environment' to vector of type 'character'

I get the same error for any example I run also. Can anyone help me figure out this error.

R code

 library(xlsx)

#create wrokbook
lengthdatacheckwb<-createWorkbook ()

#create sheet
nolengthsheet <- createSheet(wb=lengthdatacheckwb, sheetName="No Length")

R info

R version 3.3.2 (2016-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] datasets  utils     stats     graphics  grDevices methods   base     

other attached packages:
 [1] openxlsx_4.0.17     plyr_1.8.4          xlsx_0.5.7         
 [4] xlsxjars_0.6.1      rJava_0.9-8         MASS_7.3-45        
 [7] RODBC_1.3-14        latticeExtra_0.6-28 RColorBrewer_1.1-2 
[10] lattice_0.20-34    

loaded via a namespace (and not attached):
[1] tools_3.3.2  Rcpp_0.12.11 grid_3.3.2 

回答1:

Nevermind - I put xlsx::createSheet but didnt put xlsx:createWorkbook.



标签: r xlsx