Package: radian
radian: A 21 century R consoleradianis an alternative console for the R program with multiline editing and rich syntax highlight.
One would considerradianas aipythonclone for R, though its design is more aligned tojulia.Featurescross platform, runs on Windows, macOS and Linuxshell mode: hit;to enter and<backspace>to leavereticulate python repl mode: hit~to enterimproved R prompt and reticulate python promptmultiline editingsyntax highlightauto completion (reticulate autocompletion depends onjedi)unicode supportlatex completionauto matching parens/quotes.bracketed paste modeemacs/vi editing modeautomatically adjust to terminal widthread more than 4096 bytes per lineInstallationRequirements:An installation of R (version 3.4.0 or above) is required to useradian, an R installation binary for your system can be downloaded fromhttps://cran.r-project.org.python(version 3.7 or above) is also required to installradian. If your system doesn't come with a python distribution, it can be downloaded fromhttps://www.python.org/downloads/orhttps://conda.io/en/latest/miniconda.html.pipis optional but it makes the installation a bit easier.# install released versionpip3install-Uradian# to run radianradian# or the development versionpip3install-Ugit+https://github.com/randy3k/radianAlternatively, if you use conda or miniconda,condainstall-cconda-forgeradianIn this case, it is recommended to install R via conda to ensure consistency in C runtime libraries.Alias on unix systemYou could aliasrtoradianby puttingaliasr="radian"in~/.bash_profilesuch thatrwould openradianandRwould still open the traditional R console.
(Ris still useful, e.g, runningR CMD BUILD.)Settingsradiancan be customized by specifying the below options in various locations$XDG_CONFIG_HOME/radian/profileor$HOME/.config/radian/profile(Unix)%USERPROFILE%/radian/profile(Windows)$HOME/.radian_profile(Unix)%USERPROFILE%/.radian_profile(Windows).radian_profilein the working directoryThe options could be also specified in the.Rprofilefiles, however,
it is not recommended becausethe settings are not persistent when vanilla mode is used;it doesn't work well withpackratorrenv.# Do not copy the whole configuration, just specify what you need!# see https://pygments.org/styles# for a list of supported color schemes, default scheme is "native"options(radian.color_scheme="native")# either  `"emacs"` (default) or `"vi"`.options(radian.editing_mode="emacs")# enable various emacs bindings in vi insert modeoptions(radian.emacs_bindings_in_vi_insert_mode=FALSE)# show vi mode state when radian.editing_mode is `vi`options(radian.show_vi_mode_prompt=TRUE)options(radian.vi_mode_prompt="\033[0;34m[{}]\033[0m ")# indent continuation lines# turn this off if you want to copy code without the extra indentation;# but it leads to less elegent layoutoptions(radian.indent_lines=TRUE)# auto match brackets and quotesoptions(radian.auto_match=TRUE)# enable the [prompt_toolkit](https://python-prompt-toolkit.readthedocs.io/en/master/index.html) [`auto_suggest` feature](https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#auto-suggestion)# this option is experimental and is known to break python prompt, use it with cautionoptions(radian.auto_suggest=FALSE)# highlight matching bracketoptions(radian.highlight_matching_bracket=FALSE)# auto indentation for new line and curly bracesoptions(radian.auto_indentation=TRUE)options(radian.tab_size=4)# pop up completion while typingoptions(radian.complete_while_typing=TRUE)# the minimum length of prefix to trigger auto completionsoptions(radian.completion_prefix_length=2)# timeout in seconds to cancel completion if it takes too long# set it to 0 to disable itoptions(radian.completion_timeout=0.05)# add spaces around equals in function argument completionoptions(radian.completion_adding_spaces_around_equals=TRUE)# automatically adjust R buffer size based on terminal widthoptions(radian.auto_width=TRUE)# insert new line between promptsoptions(radian.insert_new_line=TRUE)# max number of history recordsoptions(radian.history_size=20000)# where the global history is stored, environmental variables will be expanded# note that "~" is expanded to %USERPROFILE% or %HOME% in Windowsoptions(radian.global_history_file="~/.radian_history")# the filename that local history is stored, this file would be used instead of# `radian.global_history_file` if it exists in the current working directoryoptions(radian.local_history_file=".radian_history")# when using history search (ctrl-r/ctrl-s in emacs mode), do not show duplicate resultsoptions(radian.history_search_no_duplicates=FALSE)# ignore case in history searchoptions(radian.history_search_ignore_case=FALSE)# do not save debug browser commands such as `Q` in historyoptions(radian.history_ignore_browser_commands=TRUE)# custom prompt for different modesoptions(radian.prompt="\033[0;34mr$>\033[0m ")options(radian.shell_prompt="\033[0;31m#!>\033[0m ")options(radian.browse_prompt="\033[0;33mBrowse[{}]>\033[0m ")# stderr color formatoptions(radian.stderr_format="\033[0;31m{}\033[0m")# enable reticulate prompt and trigger `~`options(radian.enable_reticulate_prompt=TRUE)Custom key bindings# allows user defined shortcuts, these keys should be escaped when send through the terminal.# In the following example, `esc` + `-` sends `<-` and `ctrl` + `right` sends `%>%`.# Note that in some terminals, you could mark `alt` as `escape` so you could use `alt` + `-` instead.# Also, note that some ctrl mappings are reserved. You cannot remap m, i, h, d, or coptions(radian.escape_key_map=list(list(key="-",value=" <- "),),radian.ctrl_key_map=list(list(key="right",value=" %>% ")))FAQUnicode doesn't work in Windows and R 4.2+.The latest version of R supports Unicode codepage directly. However, radian relies on Python and Python doesn't support Unicode in the way that R supports it. A workaround could be found here:https://github.com/randy3k/radian/issues/269#issuecomment-1169663251. Though it may break the ploting device (runningplot()will kill radian).I can't specify python runtime in reticulate.It is expected.radianruns on python and the python runtime used by radian is forced in
reticulate.reticulate::py_config()gives the note:NOTE: Python version was forced by the current processIn order to use radian with another python runtime, you will need to installradianon
that python environment.How to switch to a different R or specify the version of R.There are serveral options.The easiest option is to pass the path to the R binary with--r-binary, i.e.,radian --r-binary=/path/to/RAlso, one could expose the path to the R binary in thePATHvariableThe environment variableR_BINARYcould also be used to specify the path to R.The environment variableR_HOMEcould also be used to specify R home directory. Note that it is should be set as the result ofR.home(), not the directory whereRis located. For example, in Unix$envR_HOME=/usr/local/lib/RradianCannot find shared libraryPlease also make sure that R was installed with the R shared librarylibR.soorlibR.dyliborlibR.dll. On Linux, the configure flag./configure --enable-R-shlibmay be needed to install R from the source. Do not forget tomake cleanto force the recompilation of the files with the correct compiler options.Outdated setuptoolsIf you encounterThe package setup script has attempted to modify files on your system that are not within the EasyInstall build area.Please update your setuptools bypip install -U setuptoolsHow to use local history fileradianmaintains its own history file.radian_historyand doesn't use the.Rhistoryfile. A local.radian_historyis used if it is found in the launch directory. Otherwise, the global history file~/.radian_historywould be used. To override the default behavior, you could launchradianwith the options:radian --local-history,radian --global-historyorradian --no-history.Does it slow down my R program?radianonly provides a frontend to the R program, the actual running eventloop is the same as that of the traditional R console. There is no performance sacrifice (or gain) while using this modern command line interface.However, it was reported that radian may be slower when using parallel computation, specifially when using forking. User should take extra care in those cases.Nvim-R supportPutletR_app="radian"letR_cmd="R"letR_hl_term=0letR_args=[]" if you had set anyletR_bracketed_paste=1in your vim config.reticulateAuto CompletionsTo enable reticulate prompt completions, make sure thatjediis installed.pipinstalljediAlternatively, if you use conda,condainstall-cconda-forgejediPrompt not shown inside a docker containerIt maybe caused by the invalid terminal size, try runningstty sizein your terminal
to see if it returns a correct size. You could change the values of it from the environmental variables$COLUMNSand$LINESwhen you log-in the docker container.docker exec -it <container> bash -c "stty cols $COLUMNS rows $LINES && bash"Why calledradian?radianis powered by (π)thon.Creditsradianwouldn't be possible without the creative workprompt_toolkitby Jonathan Slenders.