vi input mode in R? - r

I'd like to be able to edit my R history using vi commands (e.g. ESC-/, ESC-k). I noticed a similar question here:
vi input mode in command line Matlab?
and tried the readline mods suggested in this post (doesn't R use readline?) but they don't work (for me).
Any ideas?

The Vim-R-plugin should do the trick. I have used it in Ubuntu, MacOS, and Windows 7. The developer is great and does frequent bugfixes.
To get Vim behavior in the R console you'll need to use the Conque Shell plugin, which Vim-R-plugin supports. I tried it for a day but found modality in the R command line a little tedious. All I ever use is tab completion and last command.

Related

Greek Characters in Julia Jupyter edition

I am using Julia.
I am trying to get some greek characters in Jupyter notebooks.
First I downloaded the latest version of Julia 1.6.2
For the jupyter connection I used anaconda, in julia repl i put ] add IJulia, and then I could chose the Julia kernel in Jupyter.
Then a friend suggested to download vs code (since we got a problem in the working directory with jupyter-anaconda)
In VS code we got no problem with working directories. And to work with notebooks we installed the Jupyter extension. It was working very well, but we got to this problem that we cannot get greek characters.
In Jupyter (anaconda) I could easily put greek characters, like this:
no package needed, nothing, just like that.
However in VSCode I cannot get that, nor "predictive text" or coding suggestions:
Any tips on how to solve this?
Like we are preferring VS Code and we know there's a way to get the greek characters on it, but we don't know how.
Any help is very welcomed.
Thanks in advance.
Check out the docs for the Julia extension in VS code here: https://code.visualstudio.com/docs/languages/julia. Per the comments above, make sure this is installed and you have the Julia kernel selected. You should then see the following:

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

Export output and command lines in R [duplicate]

Is there an easy way to have R record all input and output from your R session to disk while you are working with R interactively?
In R.app on Mac OS X I can do a File->Save..., but it isn't much help in recovering the commands I had entered when R crashes.
I have tried using sink(...,split=T), but it doesn't seem to do exactly what I am looking for.
Many of us use ESS / Emacs for this very reason. Saving old sessions with extension '.Rt' even gives you mode-specific commands for re-running parts of your session.
Greg Snow wrote recently on the R-help list (a very valuable resource, SO R people!):
"You may also want to look at ?TeachingDemos::txtStart as an alternative to sink, one advantage is that the commands as well as the output can be included. With a little more work you can also include graphical output into a transcript file."
r-help
Check out the savehistory() command
I'm not sure yet how to answer an answer, but there is an updated version of Ranke's vim r-plugin called r-plugin2 available here. It seems more user-friendly and robust than the original.
Emacs is good, but for those of us with a vi preference there's the vim-r plugin at:
http://www.uft.uni-bremen.de/chemie/ranke/index.php?page=vim_R_linux
It works brilliantly and has a tiny memory footprint.

R syntax highlighting in Terminal

Can we get syntax highlighting for R in the Terminal?
I've finally found a library that meets my needs.
Now I'm much happier with my coding environment.
colorout is an R package that colorizes R output when running in a terminal emulator.The package cannot be on CRAN because it changes code already loaded by R and this is prohibited by the CRAN Repository Policy. The package replaces the functions that output results and messages to R Console, and this is necessary because we cannot colorize the output without replacing these functions. To install it, do the following in R:
install.packages("devtools")
devtools::install_github("jalvesaq/colorout")
library("colorout")
# do something
Use something like ess on emacs or RStudio for syntax highlighting for R instead of expecting it to work in the terminal.
Another option now would be to use radian instead of the default R prompt.
As hd1 indicated, this is not an R question. You're asking the OSX Terminal.app to do something it's not capable of. A quick look around Google (happy Zamboni birthday!) shows Vim syntax Highlighting for highlighting within vim , or https://superuser.com/questions/72057/terminal-emulator-with-custom-color-palette , but dunno if these will run under Darwin.
EDIT: I can't stay away from the search :-) . So check out these threads: https://superuser.com/questions/400360/syntax-highlighting-in-terminal-mac-os-x , http://forums.macrumors.com/showthread.php?t=412609 , and a recommendation to install zsh , https://apple.stackexchange.com/questions/12161/os-x-terminal-must-have-utilities

Disable GUI, graphics devices in R

Is there an easy way to turn of all GUI elements in R and run it solely from the command line on OSX?
I'm trying to replicate the behavior of a remote linux terminal on my OSX machine. Thus plot() should just save a file and things like CRAN mirror selection should be text, not a Tk interface. I'm having trouble finding where to set this behavior.
I had this exact question and wanted a way to do it without changing my existing code. I usually run with graphics support but sometimes I'll run a script on the server for a larger dataset and then I just want the plots to be output somewhere automatically.
In Dirk's answer Ian Fellows gives the simple solution. On the command line in R type:
options(device=pdf)
And then any plots will be written to the current directly to an Rplots.pdf file.
If you want the files to not be plotted at all then use
options(device=NULL)
For the plots you can just direct the output to a file using the pdf() command (or png(), jpeg()...).
I don't own an OS X box, but did you try to unset the X11 environment variable DISPLAY:
DISPLAY="" R --vanilla
When I do that on Linux and query R for capabilties(), x11 comes up as FALSE as desired.
I don't run OSX but you could attempt to run R from the Terminal application, rather than the Mac OSX launcher, and see whether that runs as you need.
As Matti writes, you can send output to files using the following commands; but I don't know if that's really the substance of your question.
png("pngfile.png")
plot(foo)
title(main="bar")
dev.off()
So instead of the quartz graphical object, your output goes to the file.
Similarly, you can output what would normally appear in the terminal to a file.
sink("foo.file")

Resources