2

Windows executes this code instantly but on my Mac it takes a long time, some times more than 10 minutes, just to write two data tables of around 2000 rows each. Can some one suggest a solution please? I have used XLConnect R library. Thanks.

# 8. Write results to file
path <- dirname(normalizePath(inp.file))
out.file <- paste(path, "/Out-",basename(inp.file),sep="")
wb <- loadWorkbook(out.file, create = TRUE)
createSheet(wb, name = "Activities")
createSheet(wb, name = "Resources")

writeWorksheet(wb, ActTab, sheet = "Activities", rownames = "EventNum")
writeWorksheet(wb, ResAvail, sheet = "Resources",rownames = "EventNum")
saveWorkbook(wb)
pnuts
  • 58,317
  • 11
  • 87
  • 139
mlg
  • 75
  • 5
  • have you tried increasing the memory? they could be set differently http://stackoverflow.com/questions/1395229/increasing-or-decreasing-the-memory-available-to-r-processes try `memory.limit()` – rmuc8 Apr 02 '15 at 09:06
  • memory.limit() seems to be a Windows command, not osx? – mlg Apr 02 '15 at 09:13
  • did you type the command in R? – rmuc8 Apr 02 '15 at 09:15
  • this is what I got > memory.limit() [1] Inf Warning message: 'memory.limit()' is Windows-specific > – mlg Apr 02 '15 at 09:26

1 Answers1

1

Looks like I just cracked it. I deleted the output file from a previous run and it worked just fine. The problem seems to be with the option "create = TRUE" in loadWorkbook function. Perhaps its not working as intended, to overwrite an existing file with the same name.

mlg
  • 75
  • 5
  • 2
    You should send this question and your observation to the package maintainer to see if it's reallly a bug. – Carl Witthoft Apr 02 '15 at 11:32
  • create = TRUE works as intended here. create = TRUE will create a file if it does not yet exist but won't overwrite an existing one. Existing files will be loaded though. – Martin Studer Apr 03 '15 at 12:04