Changing Cntrl + R shortcut for Running scripts in R Windows GUI - r

Is is possible to change the "Control + R" shortcut for sending scripts from the R text editor in the Windows GUI to the R console? I'd like to change it to "Control + Enter" to be more like the shortcut on my Mac. I do all my normal work on a Mac but have to use R on a PC to interface with some PC-only computational software.
Additional tidbits:
I'd rather not run an IDE on the PC if I don't have to, though perhaps this is the solution.
I use Rstudio on my Mac, but Rstudio does not get along with the PC software I'm running

The short answer is:
"No, there are no [built-in] ways to alter the menu shortcuts in the R Console"
I'm however gathering here -community wiki style- some of suggestions posted as remarks to this questions.
One approach may be to download the R source, hack it (see circa line 625 of src/gnuwin32/editor.c: ), and build the R binary anew (see the R for Windows FAQ for the tools you need to build from source). This seems to be a rather radical approach for the mere convenience of using an alternate keystroke sequence...
A similar approach may be to create an automatic patcher program which would patch the R executable, by locating the byte patterns surrounding the compiled logic of editor.c mentioned above and replacing it with a byte sequence for the desired keystroke. This solution may be sensitive to changes in the binaries, but also avoids the build process altogether...
An easier way to achieve this is probably by using an external text editor. Most modern editors have macros or configs that can be used, for example, to execute a source command in R for the selected text.

Customizing keyboard shortcuts is made available in Rstudio 0.99.644.
See https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts for more information.

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.

Running a R console in RInside

Is it possible to run something similar to a Linux R console (which uses GNU Readline) from within a C++ program using RInside? The best option would be, if such a console would have all the nice features like the autocomplete.
The background:
I have a big solver, which has a RInside-based plugin for running small chunks of R code during a simulation. It would be nice if the user would be able to switch it to "interactive" mode and check things out as they go.
Notice:
1. I cannot just run R as a separate program, as I need it to see my objects and pointers from the main code. 2. I know about callbacks in RInside, but they do not provide any console-like capabilities.
Code: I doubt it will help, but here is my code now: https://github.com/llaniewski/TCLB/blob/RInside/src/Handlers/cbRunR.cpp.Rt

R tcltk: error when trying to display a png file depending on the OS

This is an issue I am encountering for different pieces of codes I am writing in R.
Basically, I would like to generate a window that displays a picture (a .png file). Following for instance guidances from this or this, I come up with this kind of code:
library(tcltk)
tmpFile <- tempfile(fileext = ".png")
download.file("https://www.r-project.org/logo/Rlogo.png", tmpFile)
tcl("image","create","photo", "imageLogo", file=tmpFile)
win1 <- tktoplevel()
tkpack(ttklabel(win1, image="imageLogo", compound="image"))
This works fine under Mac OS, but not on Linux nor on Windows, where I am displayed such an error message:
[tcl] couldn't recognize data in image file
I can find some workarounds when I want to display graphs, using for instance packages tkrplot or igraph. Nonetheless, I would be really eager to understand why I got such errors when running my scripts on Linux or Windows, whereas it works just fine on Mac OS.
Apologies in case this issue is obvious, but I haven't found anything about potential differences with the tcltk package depending on the OS.
Tk's native support for PNG was added in 8.6. Prior to that, you need to have the tkimg extension loaded into Tk to add the image format handler required. If your installation of Tcl/Tk that R is using is set up right, you can probably make it work with:
tclRequire("Img")
once you've initialised things sufficiently. Yes, the name used internally is “Img” for historical reasons, but that's just impossible to search for! (This is the key thing in this mailing list message from way back.)
However, upgrading the versions of Tcl and Tk to 8.6 is likely to be a better move.
Finally and a bit lately, I would like to close this issue and sum up the different suggestions that were kindly made in response of my question:
R comes along with Tcl 8.5, even with the latest version 3.3.2, which means that there is no way for embedding a PNG file with the usual command into a window created thanks to Tcl/Tk. For some reasons it is working on Mac OS, but do not expect this to work easily on other OSs.
In order to display pictures, graphs, etc. in a window generated by Tcl/Tk in R, better look for either using the GIF support (when possible) or trying alternative solutions (see the question for possible alternative options).
In case one really wants to display PNG files, the solution consists of installing Tcl 8.5 (for instance ActiveTcl) along with the extension Img. In order to use the Tcl/Tk package that you've just installed on your computer, you can refer to the R FAQ for Windows for instance (as stated in the FAQ, you need to install Tcl 8.5 - I tried with Tcl 8.6, thereby hoping to solve my issue, but it didn't work). Basically, you need to set up an environment variable (MY_TCLTK) and put the path where the package Tcl/Tk is installed. Needless to be said, Tcl/Tk is commonly used in R in order to implement GUIs; if you have to go through very complex procedures to set up the system, the package definitely loses its advantages.
Finally, since Tcl 8.6 should be available soon or later with R (already implemented in the devel version), this issue will be de facto outdated.

Syntax Highlighting for R in Macvim

I use R and I find some of the embedded editor's characteristics annoying. Typically, it would be convenient to have the possibility to add tabs or even bette to do splits like you can do it with vim.
I have a Mac running Mavericks and I use Macvim. I want to use vim as my R editor, without using it as an IDE.
However, the syntax highlighting is not convincing. The functions are not recognized for instance.
I installed the Vim-R-plugin (I followed these instructions). However, I found no change in my syntax highlighting.
Do you have any suggestions?
R-Studio is a development environment for R. It is very light and powerful and it offers some embedded themes to highlight code.
You can use it as editor only...

R2PPT crashes R; are there alternatives to R2PPT?

I am attempting to automate the insertion of JPEG images into Powerpoint. I have a macro done for that already, except using R would be infinitely better for my purposes.
The package R2PPT should do this, I understand. However, I cannot use it. For example, when I try to use PPT.Open, I understand I can do it two different ways by calling method = "rcom" or method = "RDCOMClient". Using the latter, R will always crash, sending an error report to windows. Using the former, it tells me I need to install statconnDCOM , before giving the error:
Error in PPT.Open(x) : attempt to apply non-function.
I cannot install statconnDCOM freely, as I wouldn't call this work non-commercial. So if there isn't a way to get around this issue, are there at least some free alternatives to R2PPT so that I can save several hours of manual work with a simple R code? If there is a way for me to use R2PPT, that would be ideal.
Thanks!
Edit:
I'm using R version 2.15 and downloaded the most recent version of R2PPT. Powerpoint is 2007.
Do you have administrative privileges on this machine?
There is an issue with package RDCOMClient. It needs permissions to write file rdcom.err in the root of drive C:. If you don't have privileges to write to c:, there is a rather cumbersome workaround:
Close R
Create "c:\temp" folder if it doesn't exist.
Locate on your hard drive file rdcomclient.dll. It usually placed in \R\library\RDCOMClient\libs\i386\ and in \R\library\RDCOMClient\libs\x64\ (you need to patch file which corresponds your Windows version - 32 bit or 64 bit). It's recommended to make backup copy of this files before patching.
Open rdcomclient.dll in text editor (Notepad++, for example -http://notepad-plus-plus.org/)
Find in file string c:\rdcom.err - it occurs only once.
Go into overwrite mode (usually by pressing "Ins" key). It is very important that new path will have the same number of characters as original one. Type C:\temp\e.rr instead of c:\rdcom.err
Save the file.
Now all should work fine.
Arguably not an answer, but have you looked at using Sweave/knitr to render your presentations in LaTeX using something like Beamer? (As discussed on slide 17 here.)
Wouldn't help any with getting JPGs into a PowerPoint, but would certainly make putting R-output (numerical or graphical) into a presentation much easier!
Edit: if you want to use knitr (which I recommend), here's another reference.

Resources