Source on save R file in Eclipse StatET - r

I'm starting learning R with coursera.org. I've chosen Eclipse Java Neon with StatET plugin as editor and here is my question. Is any more efficient way to loading file to R console instead writing source("file.R") after every change in this file? I mean about something like "Source on save" in RStudio.

Running R documents
What I use the most is simply selecting in the window the part I want to run and run
Ctrl+R Ctrl+R
if I want to run the whole file
CtrlA+ Ctrl+R Ctrl+R
if I want to run the R script by submitting directly
Crtl R + Ctrl D
or
right click in the document, run as
If I want to save the file first Ctrl+S
you can also use the buttons in the toolbar at the top, they will let you learn the shortcuts.
If you prefer different shortcuts.
Window>Preference>General>Keys and edit the shortcuts you want to have.

Related

Atom or Rstudio like IDE alternative for julia language

Similar to Rstudio, Atom allowed you to run code segments on interactively rather than the entire script all at once. Is there a suitable Julia language IDE that is comparable to rstudio or Atom (juno) and allows for on-the-fly execution of code blocks because Atom is being phased out?
note: Thanks for answers in vs code to obtain interactive feature hold ctrl + return will run code.
Did you try the Microsoft Visual Studio Code ? You can check how to download and setup for Julia notebook in link below.
https://github.com/julia-vscode/julia-vscode#installing-juliavs-codevs-code-julia-extension
The Best, Wr
In Microsoft VS Code you can define code cells using magic comments (## or # %% or #- can play this role - the choice is yours):
##
(your code goes here)
##
A code cell is executed by pressing Alt + Enter while the cursor is inside the cell.
At the code below I pressed Alt + Enter while being in line 10.
The keyboard shortcut can be configured by selecting in the main menu View->Command Palette or pressing Ctrl + Shift + P:
VSCode. The Julia team was working on a Julia IDE called Juno but the website now says "Juno will receive no more feature updates. Development focus has shifted to the Julia extension for VSCode", and VSCode seems to be the recommended way to develop in julia.
The Julia extension for VSCode let's you run code block by just pressing shift+enter and it uses Revise.jl to make interactive sessions better. You can see plots and other outputs right in the editor, and recenty they have even added performance monitoring/benchmarking tools.
However, if you prefer notebook-style workflows, you can use Jupyter with Julia (and the IJulia kernel) but even better imo is Pluto, which is specifically made for Julia and has some nice features such as no hidden state.

How to run Python, R, Octave or Julia using BowPad?

I try using a very light-weighted editor BowPad to edit and run codes.
Take running R as an example, which has been added to Windows PATH Environment Variable D:\R\R-3.6.2\bin\x64
I try to take some following steps:
I built a test.r writing some testing line codes as 1+2; plot(1:10)
Menu --> Run --> Configure custom commands
Command Name: run R
Command Line: D:\R\R-3.6.2\bin\R.exe $(SEL_TEXT)
$(LINE) The line where the cursor is
$(POS) the position where the cursor is
$(TAB_PATH) the path to the file of the active tab
$(TAB_NAME) the file name without extension of the current tab
$(TAB_EXT) the file extension of the current tab
$(TAB_DIR) the directory of the file of the active tab
$(SEL_TEXT) the selected text or the word at the cursor position
$(SEL_TEXT_ESCAPED) like $(SEL_TEXT) but escaped, useful for urls
When I press to choose run R to run the code, something wrong happens!
It will open a Rterm(64-bit) window each time when I run R!
it shows RGUMENT '1+2' __ignored__ or ARGUMENT 'plot(1:10)' __ignored__
Did I missing something ? BTW, can we set some shortcuts keys for running Python, R, Octave or Julia?
Also, when I reach the homepage of BowPad for more information, little usage of this software can be found!
R.exe refers to Rterm. You can use Rgui.exe instead but that won't automatically process arguments. I think what you likely want is to send the selected text to a running R session rather than starting up a new R session each time.
To do that
download this file and optionally place it on your path https://raw.githubusercontent.com/ggrothendieck/batchfiles/master/clip2r.js
in the Bowpad Run | Configure window configure a Run R command as the following (or if clip2r.js is not on your path use the entire pathname). It should be just like this with no arguments.
clip2r.js
From the Windows cmd line if Rgui is running we see that tasklist | findstr Rgui finds Rgui as the R gui process and you can create additional js scripts by editing clip2r.js replacing Rgui in the js script with whatever is the appropriate word to locate python, julia, octave or other R front end assuming again that they are running.
Now to invoke it from within Bowpad:
ensure that your Rgui session is already running and
from within Bowpad select the code you want to run and copy it to the clipboard and then invoke Run R. For example, to run everything use ctrl A ctrl C ctrl R 0 assuming that Run R is in position 0 in the configure menu. Alternately use the mouse with the Ribbon.
Regarding the comment about difficulty finding help, it looks like Bowpad is based on Scintilla so the documentation for it and the related SciTE editor likely apply to Bowpad too. You can also check the Bowpad source code on github.

Sublime 3 not interfacing with R (tried R-box and REPL)

Super basic question here:
I installed the R-box package in Sublime 3 with no problems.
I changed the path to my R.app in the SublimeREPL.sublime-settings in Sublime, although this should not make a differece on Mac.
I checked in Package Control -> R-Box:Select Program. It's set to R.
I'm simply unable to get Sublime to send code to R. Pressing Cmd+Enter does nothing (actually, it starts a new line on Sublime).
I'm running Sublime 3 on Maverics, and R version 3.2.1. But I had the same problems with Sublime 2 and a previous R version. I'm sure I'm missing something simple but I can't find any more information in the installation page.
Open up an R console by pressing Ctrl+Shift+P and typing REPL R (after a few times you’ll be able to just type R and it will come up). You can open up two windows using (Alt+Shift+2) so you can have your R code on the left and your R console on the right.
As for running the code, once you have called the R console, you have three options: To run the current line or your selected lines, press Ctrl+Shift (release) then l. To run just the selected text, press Ctrl+Shift (release) then s. To run the entire file, press Ctrl+Shift (release) then f.
Actually, I got an answer from the R-box developers, that worked perfectly:
Close Sublime Text 3, then reopen it. Then check that at the bottom right of the window it says R Extended.
If not, you need to set the Syntax on the file:
cmd+shift+P
Set Syntax: R Extended

Automate RStudio processed RMarkdown?

I have an RMarkdown file that I use to generate a nice HTML report.
The problem is, I want to be able to automate it so that it can run on a headless server. As such there will be nobody there to start Rstudio and press the 'knithtml' button and it seems that Rstudio is doing a LOT of additional magic like having it's own version of pandoc, running all the necessary commands, applying css styles etc.
How can I take this report and generate the same thing Rstudio is generating when I press the 'knithtml' button, but by just running an R script?
Thanks.
Try using
rmarkdown::render("/PATH/TO/YOUR.Rmd", output_file="/PATH/TO/YOUR/OUTPUT.html")
instead. This assumes you've got the rmarkdown library loaded on your headless box. It will use the system pandoc, but make sure it's 1.12 or higher.
Here's what knit2html does (via the "R Markdown" tab near "Console"):
Here's a side-by-side. Left is clicking the button, right is running the command:
I had the same issue. After a lot of brute force, I got the same result as RStudio with this command line:
"path\to\Rscript.exe" -e "rmarkdown::find_pandoc(dir='path/to/RStudio/bin/pandoc'); rmarkdown::render('file.Rmd')"

Is there a hack to be able to run the current line or selection in RStudio without moving the cursor?

UPDATE (April 2013): As per answer below, RStudio no longer jumps cursor on selection.
I'm running RStudio 0.97.168.
I like to use the script editor in RStudio like a console. Thus, I run a line of code and then edit it a little bit and re-run it. I often also explore objects by selecting some of the code and running the selection and then progressively altering the selection. At present RStudio always moves the cursor after running a line of code. The cursor can move to a variety of places. Typically the cursor moves to the next line of R code, but depending on the context, it could move to the end of the code block or the next line. It's really frustrating having to constantly move the cursor back to where I want it.
While I often appreciate the default cursor movement behaviour, I'd like to have the option to run the selection or the current line without the cursor moving.
I've raised this as a suggestion on RStudio support.
I'd like to be able to have a shortcut key like "Cmd+Alt+Enter" that runs the current line or selection and does not move the cursor in the script editor.
I realise that this is not currently supported, but I was wondering whether there might be some creative hack that could enable the cursor not to move after running a command or even a patch or perhaps some sort of external macro.
For anyone who ends up here in 2020:
Ctrl(or Cmd) + Enter: Will run current line and jump to the next one. If a code portion is selected, run the selected code without jumping further.
Alt + Enter: – Will run the current line of code without moving the cursor to the next line, useful if you want to run it multiple times.
(Source)
For this kind of flexibility, I suggest you use the editor Sublime Text 2, add in the package installer by Will Bond and then install the SublimeREPL package which will allow you to use an R interpreter within ST2 (or BASH prompt, Python / Ruby / whatever interpeter, concurrently if you wish).
You can then alternate between your code and the interpreter without lifting your fingers from the keyboard and your cursor will be at the same point every time when you want to switch back.
Sublime Text will also allow you to write a custom keybinding to automate this task.
I cannot recommend using Sublime Text 2 highly enough when coding for R. You can even pass files directly from ST2 into RStudio very easily if you like using the plot panes (very easy to do with the SidebarEnhancements package in ST2).
RStudio is awesome for many things -- especially now with Knitr, builds etc etc. But ST2 with an R REPL is many orders of magnitude more powerful for general code writing / editing than RStudio.
Sorry it's not RStudio specific, but it is a nice workaround!
I updated to version 0.98.83 of RStudio using the daily build section.
It appears that at some point in recent versions of RStudio, the cursor no longer jumps when code is run from a selection in the script window.
That's great news.

Resources