{"action":"created","issue":{"url":"https://api.github.com/repos/awalker89/openxlsx/issues/129","labels_url":"https://api.github.com/repos/awalker89/openxlsx/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/awalker89/openxlsx/issues/129/comments","events_url":"https://api.github.com/repos/awalker89/openxlsx/issues/129/events","html_url":"https://github.com/awalker89/openxlsx/issues/129","id":115348321,"number":129,"title":"insertPlot using batch file not working","user":{"login":"JimmyG9","id":15676556,"avatar_url":"https://avatars.githubusercontent.com/u/15676556?v=3","gravatar_id":"","url":"https://api.github.com/users/JimmyG9","html_url":"https://github.com/JimmyG9","followers_url":"https://api.github.com/users/JimmyG9/followers","following_url":"https://api.github.com/users/JimmyG9/following{/other_user}","gists_url":"https://api.github.com/users/JimmyG9/gists{/gist_id}","starred_url":"https://api.github.com/users/JimmyG9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimmyG9/subscriptions","organizations_url":"https://api.github.com/users/JimmyG9/orgs","repos_url":"https://api.github.com/users/JimmyG9/repos","events_url":"https://api.github.com/users/JimmyG9/events{/privacy}","received_events_url":"https://api.github.com/users/JimmyG9/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-05T18:51:17Z","updated_at":"2015-11-05T22:00:32Z","closed_at":"2015-11-05T22:00:32Z","body":"Is it possible to insert a plot into an XLSX file using an R batch file and RScript.exe?\r\n\r\nI can successfully do this using the R Gui. However, if I run an R batch file using RScript.exe, the plot is created as an adjacent file to the XLSX file and is not inserted into the \"Graph\" worksheet.\r\n\r\nExample R script:\r\n```\r\nlibrary(openxlsx)\r\nlibrary(ggplot2)\r\n\r\nwb <- createWorkbook()\r\naddWorksheet(wb, \"Data\")\r\naddWorksheet(wb, \"Graph\", gridLines=FALSE)\r\n\r\ndf <- data.frame(c(1:5), c(5:1))\r\nnames(df) <- c(\"x\",\"y\")\r\nwriteData(wb, \"Data\", df)\r\n\r\np <- ggplot(aes(x=x, y=y), data=df) + geom_line(size=1, colour=\"blue\")\r\nprint(p)    #plot needs to be showing\r\ninsertPlot(wb, \"Graph\", width=11.18, height=7.82, fileType=\"png\", units=\"in\")\r\n\r\nsaveWorkbook(wb, \"test.xlsx\", overwrite=TRUE)\r\n```\r\n\r\nR Batch file script:\r\n```\r\n\"C:\\Program Files\\R\\R-3.1.3\\bin\\RScript.exe\" --no-save --no-environ --no-init-file --no-restore --no-Rconsole \"C:\\temp\\insertPlotExample.R\"\r\n```\r\nIs this possible? Or am I doing something wrong?"},"comment":{"url":"https://api.github.com/repos/awalker89/openxlsx/issues/comments/154208988","html_url":"https://github.com/awalker89/openxlsx/issues/129#issuecomment-154208988","issue_url":"https://api.github.com/repos/awalker89/openxlsx/issues/129","id":154208988,"user":{"login":"JimmyG9","id":15676556,"avatar_url":"https://avatars.githubusercontent.com/u/15676556?v=3","gravatar_id":"","url":"https://api.github.com/users/JimmyG9","html_url":"https://github.com/JimmyG9","followers_url":"https://api.github.com/users/JimmyG9/followers","following_url":"https://api.github.com/users/JimmyG9/following{/other_user}","gists_url":"https://api.github.com/users/JimmyG9/gists{/gist_id}","starred_url":"https://api.github.com/users/JimmyG9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimmyG9/subscriptions","organizations_url":"https://api.github.com/users/JimmyG9/orgs","repos_url":"https://api.github.com/users/JimmyG9/repos","events_url":"https://api.github.com/users/JimmyG9/events{/privacy}","received_events_url":"https://api.github.com/users/JimmyG9/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T22:00:32Z","updated_at":"2015-11-05T22:00:32Z","body":"I may have found my answer. The key is to use x11() or windows() before running the plot to get this to work. However, this is not using Rscript in its designed way. Seems I need to go back to the drawing board. Please close this issue, sorry for troubles."}}