SendCode icon indicating copy to clipboard operation
SendCode copied to clipboard

Sending R Code Using SendCode

Open crdob opened this issue 6 years ago • 11 comments

Hi! I am having difficulty sending R code using SendCode. I have installed SendCode and SublimeREPL using Package Control on Sublime Text 3. If I create a new R script, set my syntax to "R", set my SendCode program to "SublimeREPL", and press CMD+B, then the output appears in a new component of the Sublime Text window at the bottom of the window. However, if my R script contains a line with plot( ), the plot does not appear after running the script in this fashion. Any help would be truly appreciated!

crdob avatar Jan 09 '19 00:01 crdob

First of all, I really don't recommend SublimeREPL. It has not been updated and maintained. Try Terminus instead.

randy3k avatar Jan 09 '19 03:01 randy3k

Thank you for your advice! I have removed the SublimeREPL package and installed the Terminus package, but I am still having the same problem: Sublime will display the plot if I use XQuartz by calling x11( ) before using plot( ), but it will not display the plot, otherwise.

crdob avatar Jan 09 '19 18:01 crdob

Are you on a Mac? I don’t experience what you have, did you change the default graphic device?

randy3k avatar Jan 09 '19 20:01 randy3k

I am on a Mac. I have not changed the default graphic device. Even if I use XQuartz, the plot will only display for a second and then disappear.

crdob avatar Jan 09 '19 23:01 crdob

The default device on Mac is quartz(), could you try quartz() instead of x11()?

randy3k avatar Jan 10 '19 02:01 randy3k

I tried using quartz( ). There is no change to the problem: The plot will display for one second and then disappear.

crdob avatar Jan 10 '19 16:01 crdob

TBH, I have no idea why it happens to you. The plotting function is working on my mac.

randy3k avatar Jan 10 '19 20:01 randy3k

I changed my "Build With..." setting to "R - Source File" and now it works properly. I recall a note on the Terminus information page suggesting that this might be required, but I must have made a mistake. Now, when I compile, I obtain the correct plot, but the output simply says, "source("extension/filename.R")". I would prefer if I could view the output directly. Is this possible?

crdob avatar Jan 10 '19 21:01 crdob

I still do not completely understand your usecase. Are you trying to send a piece of R code to the R Console, or just want to run the R script file?

randy3k avatar Jan 10 '19 23:01 randy3k

If I have an R script open in Sublime and have a default shell panel open and running R (using Terminus), then I can select all of my code in the script and send it to the Terminus panel using CMD+ENTER. I would like this functionality with CMD+B instead of having to select my code.

Currently, CMD+B will run the script using source( ) but I prefer the functionality described above so that I can immediately view the output of the script in the panel, and so I can sometimes send lines with CMD+ENTER and sometimes send the whole script with CMD+B. Does this help clarify?

crdob avatar Jan 11 '19 16:01 crdob

I can sometimes send lines with CMD+ENTER and sometimes send the whole script with CMD+B

You have totally spoken out the two main functions of SendCode unless something is not working as expected. cmd+enter will send the selection to the R console and cmd+b will source the script.

randy3k avatar Jan 11 '19 16:01 randy3k