21世纪的R控制台
radian的Python项目详细描述
弧度:21世纪的R控制台
radian是r程序的可选控制台,具有多行编辑和丰富的语法高亮显示。 人们会认为radian是r的ipython克隆,尽管它的设计更符合julia。
功能
- 跨平台,在Windows、MacOS和Linux上运行
- shell模式:按
;
进入,按<backspace>
离开 - 网状python repl mode:点击
~
进入 - 改进的r提示符和网状python提示符
- 多行编辑
- 语法突出显示
- 自动完成(网状自动完成依赖于
jedi
)
- Unicode支持
- 自动匹配括号/引号。
- 带括号的粘贴模式
- emacs/vi编辑模式
- 自动调整到终端宽度
- 每行读取超过4096字节
安装
要求:
- 需要安装r(3.4.0或更高版本)才能使用radian,您系统的r安装二进制文件可以从https://cran.r-project.org下载。
python
也需要安装radian。如果您的系统没有python发行版,可以从https://conda.io/en/latest/miniconda.html下载。版本2和版本3都应该可以工作,不过建议使用python 3。pip
是可选的,但它使安装更加容易。
# install released version pip install -U radian # to run radian radian
# or the development version
pip install -U git+https://github.com/randy3k/radian
Unix系统上的别名
您可以将r
别名设为radian,方法是将
aliasr="radian"
在~/.bash_profile
中,r
将打开radian并且R
仍将打开传统的r控制台。
(R
仍然有用,例如,运行R CMD BUILD
。)
设置
radian可以通过.Rprofile
文件中的options
自定义。此文件通常位于用户主目录中。
不要复制整个配置,只需在.Rprofile
# see https://help.farbox.com/pygments.html# 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")# 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=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)# timeout in seconds to cancel completion if it takes too long# set it to 0 to disable itoptions(radian.completion_timeout=0.05)# automatically adjust R buffer size based on terminal widthoptions(radian.auto_width=TRUE)# insert new line between promptsoptions(radian.insert_new_line=TRUE)# when using history search (ctrl-r/ctrl-s in emacs mode), do not show duplicate resultsoptions(radian.history_search_no_duplicates=FALSE)# 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 ")# supress the loading message for reticulateoptions(radian.suppress_reticulate_message=FALSE)# enable reticulate prompt and trigger `~`options(radian.enable_reticulate_prompt=TRUE)# allows user defined shortcuts, these keys should be escaped when send through the terminal.# In the following example, `esc` + `-` sends `<-` and `esc` + `m` sends `%>%`.# Note that in some terminals, you could mark `alt` as `escape` so you could use `alt` + `-` instead.options(radian.escape_key_map=list(list(key="-",value="<-"),list(key="m",value="%>%")))
常见问题解答
如何指定R\U原点
如果radian无法自动找到r的安装位置。最好的选择是将r二进制文件公开给系统PATH
变量。
在linux/macos中,还可以导出环境变量R_HOME
。例如,
$ exportR_HOME=/usr/local/lib/R $ radian
还请确保r与r共享库libR.so
或libR.dylib
或libR.dll
一起安装。在linux上,可能需要标记--enable-R-shlib
才能从源代码安装r。
如何使用本地历史文件
radian维护自己的历史文件.radian_history
,而不使用.Rhistory
文件。如果在启动目录中找到本地.radian_history
,则使用它。否则,将使用全局历史文件~/.radian_history
。要覆盖默认行为,可以启动radian,选项为:radian --local-history
、radian --global-history
或radian --no-history
。
它会减慢我的R程序吗?
radian只提供r程序的前端,实际运行的eventloop与传统的r控制台相同。在使用这个现代命令行界面时,没有性能牺牲(或增益)。
NVIM-R支持
放置
let R_app ="radian"let R_cmd ="R"let R_hl_term =0let R_args = [] " if you had set anylet R_bracketed_paste =1
在你的vim配置中。
reticulate
自动完成
要启用网状提示完成,请确保安装了jedi
。
pip install jedi
读取线错误
libreadline.so.6: undefined symbol: PC
如果python和r使用libreadline
的不同两个版本,则可能会发生这种情况。您可以先尝试预加载系统libreadline.so
。
env LD_PRELOAD=/lib64/libreadline.so.6 radian
setTimeLimit
不工作
radian使用函数setTimeLimit
设置长时间完成的超时。用户可能会注意到setTimeLimit
在
全球环境。解决方法是将代码放在块或函数中,
{setTimeLimit(1)while(1){}setTimeLimit()}
Docker容器中未显示提示
它是M可能是由于终端大小无效,请尝试在终端中运行stty size
看看它返回的大小是否正确。你可以从环境变量中改变它的值
^登录Docker容器时{$LINES
。
docker exec -it <container> bash -c "stty cols $COLUMNS rows $LINES && bash"
为什么叫radian?
radian由(π)thon提供能量。
学分
radian不可能完成jonathan slenders的创造性工作prompt_toolkit。