{"action":"created","issue":{"url":"https://api.github.com/repos/awalker89/openxlsx/issues/116","labels_url":"https://api.github.com/repos/awalker89/openxlsx/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/awalker89/openxlsx/issues/116/comments","events_url":"https://api.github.com/repos/awalker89/openxlsx/issues/116/events","html_url":"https://github.com/awalker89/openxlsx/issues/116","id":100179559,"number":116,"title":"Error in comment_list[[i]]: subscript out of bounds","user":{"login":"r2evans","id":5815808,"avatar_url":"https://avatars.githubusercontent.com/u/5815808?v=3","gravatar_id":"","url":"https://api.github.com/users/r2evans","html_url":"https://github.com/r2evans","followers_url":"https://api.github.com/users/r2evans/followers","following_url":"https://api.github.com/users/r2evans/following{/other_user}","gists_url":"https://api.github.com/users/r2evans/gists{/gist_id}","starred_url":"https://api.github.com/users/r2evans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r2evans/subscriptions","organizations_url":"https://api.github.com/users/r2evans/orgs","repos_url":"https://api.github.com/users/r2evans/repos","events_url":"https://api.github.com/users/r2evans/events{/privacy}","received_events_url":"https://api.github.com/users/r2evans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-10T22:02:25Z","updated_at":"2015-08-16T06:39:46Z","closed_at":null,"body":"Up front: I'm dealing with a large spreadsheet, and I can't give it to you (proprietary), so I'm trying to reproduce the error with smaller data.\r\n\r\nI'm getting `Error in comment_list[[i]] : subscript out of bounds` when trying to save a worksheet. The sequence:\r\n\r\n```r\r\n## \"out\" is a large data.frame\r\nwb <- loadWorkbook('template.xlsx')\r\n## normally I do something more here, but in testing I do nothing\r\nsaveWorkbook(wb, file='newdata.xlsx', overwrite=TRUE)\r\n```\r\n\r\nSo I started debugging, specifically `openxlsx:::writeCommentXML`. The first time, it completes just fine. The second time, `comments` is an empty list, causing (as you might imagine) the first line in the loop to fail:\r\n\r\n```r\r\nauthorInd <- which(authors == comment_list[[i]]$author) - 1L\r\n```\r\n\r\nThe workbook has five worksheets. They are all very similarly structured: the first three have graphs and some tables doing lookups to the last two worksheets, which are a pivot-table and a \"medium-large\" data table (only 37K rows, so not huge). There are no external data source links.\r\n\r\nIt may be related to an SO question [#31595749](http://stackoverflow.com/questions/31595749/openxlsx-number-of-worksheets) (gives the same error), but I'm not certain.\r\n\r\nThis is using a freshly-pulled version from github.\r\n\r\nOther than getting you a MWE, is there anything else I can do to help troubleshoot this?\r\n\r\n~bill\r\n\r\n```r\r\nsessionInfo()\r\n## R version 3.2.1 (2015-06-18)\r\n## Platform: x86_64-w64-mingw32/x64 (64-bit)\r\n## Running under: Windows 8 x64 (build 9200)\r\n## locale:\r\n## [1] LC_COLLATE=English_United States.1252 \r\n## [2] LC_CTYPE=English_United States.1252   \r\n## [3] LC_MONETARY=English_United States.1252\r\n## [4] LC_NUMERIC=C                          \r\n## [5] LC_TIME=English_United States.1252    \r\n## attached base packages:\r\n## [1] grid      stats     graphics  grDevices utils     datasets  methods  \r\n## [8] base     \r\n## other attached packages:\r\n## [1] openxlsx_3.0.7     ggplot2_1.0.1      gridBase_0.4-7     RColorBrewer_1.1-2\r\n## [5] rgeos_0.3-11       sp_1.1-1           tidyr_0.2.0        dplyr_0.4.1       \r\n## [9] r2_0.4.15         \r\n## loaded via a namespace (and not attached):\r\n##  [1] Rcpp_0.12.0      xml2_0.1.1       magrittr_1.5     devtools_1.8.0  \r\n##  [5] MASS_7.3-43      munsell_0.4.2    colorspace_1.2-6 lattice_0.20-33 \r\n##  [9] stringr_1.0.0    plyr_1.8.3       tools_3.2.1      parallel_3.2.1  \r\n## [13] gtable_0.1.2     DBI_0.3.1        git2r_0.10.1     rversions_1.0.2 \r\n## [17] htmltools_0.2.6  lazyeval_0.1.10  assertthat_0.1   digest_0.6.8    \r\n## [21] reshape2_1.4.1   curl_0.9.1       memoise_0.2.1    rmarkdown_0.7   \r\n## [25] stringi_0.5-5    compiler_3.2.1   scales_0.2.5     proto_0.3-10    \r\n```"},"comment":{"url":"https://api.github.com/repos/awalker89/openxlsx/issues/comments/131495249","html_url":"https://github.com/awalker89/openxlsx/issues/116#issuecomment-131495249","issue_url":"https://api.github.com/repos/awalker89/openxlsx/issues/116","id":131495249,"user":{"login":"r2evans","id":5815808,"avatar_url":"https://avatars.githubusercontent.com/u/5815808?v=3","gravatar_id":"","url":"https://api.github.com/users/r2evans","html_url":"https://github.com/r2evans","followers_url":"https://api.github.com/users/r2evans/followers","following_url":"https://api.github.com/users/r2evans/following{/other_user}","gists_url":"https://api.github.com/users/r2evans/gists{/gist_id}","starred_url":"https://api.github.com/users/r2evans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r2evans/subscriptions","organizations_url":"https://api.github.com/users/r2evans/orgs","repos_url":"https://api.github.com/users/r2evans/repos","events_url":"https://api.github.com/users/r2evans/events{/privacy}","received_events_url":"https://api.github.com/users/r2evans/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T06:39:46Z","updated_at":"2015-08-16T06:39:46Z","body":"Can no longer reproduce this, thanks."}}