Giter VIP home page Giter VIP logo

radian's Introduction

radian: A 21 century R console

Main codecov Conda version

radian is an alternative console for the R program with multiline editing and rich syntax highlight. One would consider radian as a ipython clone for R, though its design is more aligned to julia.

Features

  • cross platform, runs on Windows, macOS and Linux
  • shell mode: hit ; to enter and <backspace> to leave
  • reticulate python repl mode: hit ~ to enter
  • improved R prompt and reticulate python prompt
    • multiline editing
    • syntax highlight
    • auto completion (reticulate autocompletion depends on jedi)
  • unicode support
  • latex completion
  • auto matching parens/quotes.
  • bracketed paste mode
  • emacs/vi editing mode
  • automatically adjust to terminal width
  • read more than 4096 bytes per line

Installation

Requirements:

# install released version
pip3 install -U radian
# to run radian
radian
# or the development version
pip3 install -U git+https://github.com/randy3k/radian

Alternatively, if you use conda or miniconda,

conda install -c conda-forge radian

In this case, it is recommended to install R via conda to ensure consistency in C runtime libraries.

Alias on unix system

You could alias r to radian by putting

alias r="radian"

in ~/.bash_profile such that r would open radian and R would still open the traditional R console. (R is still useful, e.g, running R CMD BUILD.)

Settings

radian can be customized by specifying the below options in various locations

  • $XDG_CONFIG_HOME/radian/profile or $HOME/.config/radian/profile (Unix)
  • %USERPROFILE%/radian/profile (Windows)
  • $HOME/.radian_profile (Unix)
  • %USERPROFILE%/.radian_profile (Windows)
  • .radian_profile in the working directory

The options could be also specified in the .Rprofile files, however, it is not recommended because

  1. the settings are not persistent when vanilla mode is used;
  2. it doesn't work well with packrat or renv.
# 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 mode
options(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 layout
options(radian.indent_lines = TRUE)

# auto match brackets and quotes
options(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 caution
options(radian.auto_suggest = FALSE)

# highlight matching bracket
options(radian.highlight_matching_bracket = FALSE)

# auto indentation for new line and curly braces
options(radian.auto_indentation = TRUE)
options(radian.tab_size = 4)

# pop up completion while typing
options(radian.complete_while_typing = TRUE)
# the minimum length of prefix to trigger auto completions
options(radian.completion_prefix_length = 2)
# timeout in seconds to cancel completion if it takes too long
# set it to 0 to disable it
options(radian.completion_timeout = 0.05)
# add spaces around equals in function argument completion
options(radian.completion_adding_spaces_around_equals = TRUE)

# automatically adjust R buffer size based on terminal width
options(radian.auto_width = TRUE)

# insert new line between prompts
options(radian.insert_new_line = TRUE)

# max number of history records
options(radian.history_size = 20000)
# where the global history is stored, environmental variables will be expanded
# note that "~" is expanded to %USERPROFILE% or %HOME% in Windows
options(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 directory
options(radian.local_history_file = ".radian_history")
# when using history search (ctrl-r/ctrl-s in emacs mode), do not show duplicate results
options(radian.history_search_no_duplicates = FALSE)
# ignore case in history search
options(radian.history_search_ignore_case = FALSE)
# do not save debug browser commands such as `Q` in history
options(radian.history_ignore_browser_commands = TRUE)

# custom prompt for different modes
options(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 format
options(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 c
options(
    radian.escape_key_map = list(
        list(key = "-", value = " <- "),
    ),
    radian.ctrl_key_map = list(
        list(key = "right", value = " %>% ")
    )
)

FAQ

Unicode 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: #269 (comment). Though it may break the ploting device (running plot() will kill radian).

I can't specify python runtime in reticulate.

It is expected. radian runs 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 process

In order to use radian with another python runtime, you will need to install radian on 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/R
  • Also, one could expose the path to the R binary in the PATH variable
  • The environment variable R_BINARY could also be used to specify the path to R.
  • The environment variable R_HOME could also be used to specify R home directory. Note that it is should be set as the result of R.home(), not the directory where R is located. For example, in Unix
$ env R_HOME=/usr/local/lib/R radian

Cannot find shared library

Please also make sure that R was installed with the R shared library libR.so or libR.dylib or libR.dll. On Linux, the configure flag ./configure --enable-R-shlib may be needed to install R from the source. Do not forget to make clean to force the recompilation of the files with the correct compiler options.

Outdated setuptools

If you encounter

The package setup script has attempted to modify files on your system that are not within the EasyInstall build area.

Please update your setuptools by

pip install -U setuptools

How to use local history file

radian maintains its own history file .radian_history and doesn't use the .Rhistory file. A local .radian_history is used if it is found in the launch directory. Otherwise, the global history file ~/.radian_history would be used. To override the default behavior, you could launch radian with the options: radian --local-history, radian --global-history or radian --no-history.

Does it slow down my R program?

radian only 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 support

Put

let R_app = "radian"
let R_cmd = "R"
let R_hl_term = 0
let R_args = []  " if you had set any
let R_bracketed_paste = 1

in your vim config.

reticulate Auto Completions

To enable reticulate prompt completions, make sure that jedi is installed.

pip install jedi

Alternatively, if you use conda,

conda install -c conda-forge jedi

Prompt not shown inside a docker container

It maybe caused by the invalid terminal size, try running stty size in your terminal to see if it returns a correct size. You could change the values of it from the environmental variables $COLUMNS and $LINES when you log-in the docker container.

docker exec -it <container> bash -c "stty cols $COLUMNS rows $LINES && bash"

Why called radian?

radian is powered by (π)thon.

Credits

radian wouldn't be possible without the creative work prompt_toolkit by Jonathan Slenders.

radian's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

radian's Issues

traceback

is rice supposed to work in windows environment? I get the following traceback trying to run rice from cmd:

> C:\Users\farid>rice
Traceback (most recent call last):
  File "C:\Python27\Scripts\rice-script.py", line 9, in <module>
    load_entry_point('rice==0.0.9', 'console_scripts', 'rice')()
  File "c:\python27\lib\site-packages\rice\__init__.py", line 19, in main
    RiceApplication().run()
  File "c:\python27\lib\site-packages\rice\application.py", line 247, in run
    mp = create_multi_prompt()
  File "c:\python27\lib\site-packages\rice\application.py", line 224, in create_multi_prompt
    input=vt100 if not is_windows() else None
  File "c:\python27\lib\site-packages\rice\application.py", line 50, in __init__
    super(MultiPrompt, self).__init__(*args, **kwargs)
  File "c:\python27\lib\site-packages\rice\deps\prompt_toolkit\shortcuts\prompt.py", line 256, in __init__
    input = input or get_default_input()
  File "c:\python27\lib\site-packages\rice\deps\prompt_toolkit\input\defaults.py", line 37, in get_default_input
    return create_input()
  File "c:\python27\lib\site-packages\rice\deps\prompt_toolkit\input\defaults.py", line 18, in create_input
    from .win32 import Win32Input
  File "c:\python27\lib\site-packages\rice\deps\prompt_toolkit\input\win32.py", line 227
    yield KeyPress(Keys.BracketedPaste, ''.join(data))
SyntaxError: 'return' with argument inside generator

my %r_home% is set to "

> C:\Users\farid>echo %r_home%
C:\Program Files\R\R-3.4.1

Detect when running R via Rice?

Is there a way to detect from within R that it's running via Rice? Scanning options and env variables, I found env var _ was set to /use/local/bin/rice but not sure if that's reliable, shell specific, or cross platform;

>  env <- Sys.getenv()                                                                                                                                                                                       
>  env[grep("rice", env, ignore.case = TRUE)]                                                                                                                           
_                                                 /usr/local/bin/rice

I'm asking because one often wanna use different settings (e.g. R prompt) for different terminals. If I there's a straightforward way to detect it, I'll add it to the startup package so R startup files can be included using file / directory names containing rice=TRUE and rice=FALSE.

PS. Rice looks really nice and promising. The fact that it also works over SSH is neat.

rtichoke for Android / termux

I have R running in termux on my android tablet. I would love to have the benefits of the rtichoke terminal. Presently, rtichoke terminates with message 'cannot locate R share library'. The os is identified by python as 'linux', however I think termux could be identified by looking for the $PREFIX variable? Would it be possible to test for Android/termux and locate the R library in the termux sandbox? Could this be achieved by my termux configuration, or would it require extra code in session.py?

Proper table printing broken with R 3.5

Setup:

  • R 3.5.0
  • rtichoke 0.1.2
  • Windows 10
  • ConEmu

Reproducible example:

data.frame(a = 1:2, x = c("a", "b"))
#> ☻ÿþa♥ÿþ ☻ÿþx♥ÿþ
#> ☻ÿþ1♥ÿþ ☻ÿþ1♥ÿþ ☻ÿþa♥ÿþ
#> ☻ÿþ2♥ÿþ ☻ÿþ2♥ÿþ ☻ÿþb♥ÿþ

Holding down Ctrl+C causes rice to exit

If I open rice, then hold down Ctrl + C to interrupt for a while, rice is closed and control is returned to the console. Text input in the terminal is also no longer echoed; executing stty echo brings terminal input back.

No syntax colors in TerminalView

Hello. Using the latest version of rtchoke, I've noticed that a lot of colors that show up in a regular terminal (say iTerm2 in MacOS) are not displayed when using TerminalView in Sublime Text. For instance, quoted strings show up as a different color when using iTerm, but not TerminalView.

A pretty minor thing, but I thought I should report it.

Customized R prompt not working in Rice

Nice little tool !
I have a line in my ~/.Rprofile:

options(prompt="\033[0;36mR>>\033[0m"

to customize the R prompt style and color. It worked in R console and in RStudio daily build(yes, stable build does not support this yet ), but Rice won't parse it.

Another thing is that when I type in Rice, the code completion pops up and I use UP-DOWN arrow key to navigate through all cadidate, but when I hit ENTER, the line will be submitted and ran, which is not good logci. In zsh or RStudio, where code completion is implemented, hitting ENTER will usually just input the code completion candidate you choose, not run it immediatly. This is annoying because when I am typing and using code completion, it usually means the line is not done yet. For example, when I input library(MA, MASS pops up and I navigate to it and hit ENTER, the line will run. However, a right braket is absent and the code definitely won't run properly.

HIST_IGNORE_DUPS equivalent setting for history

ZSH has a HIST_IGNORE_DUPS option which will

not enter command lines into the history list if they are duplicates of the previous event.

It would be nice to have a similar option for the rice history, having duplicate events makes using the incremental search more cumbersome than it otherwise would be.

Another option would be implementing HIST_FIND_NO_DUPS, which simply does not return duplicate entries when searching the history.

Basically if I am using incremental backwards search I don't want to go through the same entry multiple times.

Rice opens 32bit version of R instead of 64bit and fails to load libraries

Hello, I tried to setup rice on Win10 64bit, miniconda 64.

rice opens R 32:

R version 3.4.3 (2017-11-30) -- Kite-Eating Tree
Platform: x86_64-w64-mingw32

but R command opens R 64:

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

but in rice library(dplyr) [or any other library] show error:

> Error: package or namespace load failed for ‘dplyr’ in inDL(x, as.logical(local), as.logical(now), ...):
>  unable to load shared object 'C:/Users/vydra/Documents/R/R-3.4.3/library/stats/libs/x64/stats.dll'

this does not happen in plain R terminal, as it opens R64.
Is it possible to force rice to load R 64 version?

Best regards,
Jan

Indentation when copying mulit-line functions

If you copy a multi-line function into a rice terminal rice adds extra indentation.

Given a function

foo <- function(x) {
  x <- x + 1
  x <- x + 2
  x <- x + 3
}

If I open rice and copy the full lines into rice I get the following

rice
R version 3.4.1 Patched (2017-08-06 r73048) -- Single Candle
Platform: x86_64-apple-darwin15.6.0

r$> foo <- function(x) {
      x <- x + 1
        x <- x + 2
          x <- x + 3
          }
r$>

I guess due to the prompt toolkit trying to be helpful for python's significant whitespace. But since R doesn't have indentation significant whitespace it would be nicer if this reproduced the original formatting.

You get better the expected behavior if you copy the full function as a block rather than line-by-line

RuntimeError: Cannot locate R share library.

When run rice in mac:

Traceback (most recent call last):
  File "/usr/local/bin/rice", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/rice/__init__.py", line 41, in main
    RiceApplication().run(options)
  File "/Library/Python/2.7/site-packages/rice/riceapp.py", line 268, in run
    rsession = RSession()
  File "/Library/Python/2.7/site-packages/rice/session.py", line 83, in __init__
    raise RuntimeError("Cannot locate R share library.")
RuntimeError: Cannot locate R share library.

Newlines at end of prompt

There always seem to be 5 newlines at the end of the prompt.

Is there a way to use all lines available in the terminal?

Scrolling in xfce terminal is broken

Hi, I wanted to let you know that scrolling in xfce4 terminal doesn't work. If there's output larger than window and I want to scroll up, it immediately resets back to active prompt. I tested KDE konsole also, where it works as expected. Just wanted to let you know, anyway thanks for great R repl.

Maintain and read `.Rhistory` / in-memory history

rice seems to maintain it's own history file independant of the R native .Rhistory. This is fine, but it should really continue to update R's internal history as well. The current behavior is a problem when trying to use R's debugger (with browser()) because you no longer have access to previous commands.

Also in general use of browser() seems to break out of the rice() shell completely, it would be great to be able to continue to use rice features in that case (I am not sure if it is possible however).

UnicodeDecodeError whit non-ascii character in rtichoke.prompt using rtichoke-0.2.0.dev0 on python 2.7

Works no problem in rtichoke 1.9.0/python2.7 or rtichoke-0.2.0.dev0/python3.6
maybe not a bug worth worrying about, but maybe remove python2 support?

this is the offending line in my .Rprofile: rtichoke.prompt = "\033[0;34m🐰 >\033[0m ". (I like my little rabbit when i do my data analysis ;))

i'm running macOS 10.13.4, R 3.5.0 (x86_64-apple-darwin15.6.0 (64-bit))

Traceback:

Traceback (most recent call last):
  File "/usr/local/bin/rtichoke", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/rtichoke/__init__.py", line 54, in main
    RtichokeApplication(r_home).run(options)
  File "/usr/local/lib/python2.7/site-packages/rtichoke/rtichokeapp.py", line 163, in run
    session_initialize(session)
  File "/usr/local/lib/python2.7/site-packages/rtichoke/prompt.py", line 165, in session_initialize
    prompt = interface.get_option("rtichoke.prompt", None)
  File "/usr/local/lib/python2.7/site-packages/rapi/interface.py", line 383, in get_option
    ret = rcopy(Rf_GetOption1(Rf_install(key.encode())))
  File "/usr/local/lib/python2.7/site-packages/rapi/dispatch.py", line 48, in __call__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/rapi/interface.py", line 352, in rcopy
    return rcopy(T, s)
  File "/usr/local/lib/python2.7/site-packages/rapi/dispatch.py", line 48, in __call__
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/rapi/interface.py", line 261, in rcopy
    return CHAR(STRING_ELT(s, 0)).decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)

rice starting up with the debug prompt

as of rice version 0.0.13 it seems to be starting up with the debug prompt rather than the regular one. I can fix it by explicitly setting a prompt.

> rice
R version 3.4.1 Patched (2017-08-06 r73048) -- Single Candle
Platform: x86_64-apple-darwin15.6.0

debug%>

debug%> options(prompt = "> ")

> 

This is likely a regression in relation to #9

A way to prevent bottom padding of lines when using rice

It seems like rice does something to add a padding of a few empty lines in the console after a command is run. Here is an example:

screenshot 2017-09-19 23 32 15

I ran the command options(), which has a lot of output that causes the screen to scroll. What I expect from all applications I've used in the terminal is that the output takes up to the last line in the window. But rice adds a few lines at the bottom. I also see this when using rice with Nvim-R.

Is there a way to prevent that from happening? When using Nvim-R, I have the console at the bottom, so this padding hides more of the last command's output than is needed.

Thanks :)

problem of colorscheme

From 0.0.41, the colorscheme was changed. When I used gnome-terminal and light solarized colorscheme, the color of editing text was too light to be read. I have to use dark colorscheme or version 0.0.40.

Cannot type after sending text to console

This is a strange one that only started after I switched from rice to rtichoke on the weekend. I've replicated the same behaviour on two separate machines (both Ubuntu), in VSCode and RStudio. If I send R code from an editor pane to a terminal running rtichoke in either program, the code executes fine, but after this the program enters a bugged state where I can no longer view text typed directly into rtichoke.

In this state, when I make keystrokes the cursor stays stuck immediately after the prompt. However if I press 'enter', rtichoke will run whatever I typed and produce output. So it is receiving input, just not displaying anything. I haven't found any way to recover from this state.

If I start rtichoke in a terminal and do not send code to it from an editor pane, it works normally.

Edit: I've tested if preloadeding any dynamic libs, as discussed in out thread, is the cause. It does not appear to be.

rtichoke not working with Emacs Shell (eshell)

Hi,

Thanks again for this great REPL, I always wanted to have something a la IPython.
I have an issue with Emacs shell (eshell), I can use IPython in eshell but not rtichoke (see screenshot).
Find below the error message

Error in options(width = 0L) : 
  invalid 'width' parameter, allowed 10...10000
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/usr/lib/python3.6/site-packages/rtichoke/callbacks.py", line 17, in _read_console
    text = get_text(p.decode(ENCODING), add_history)
  File "/usr/lib/python3.6/site-packages/rtichoke/rtichokeapp.py", line 162, in result_from_prompt
    self.app_initialize(mp)
  File "/usr/lib/python3.6/site-packages/rtichoke/rtichokeapp.py", line 116, in app_initialize
    interface.set_option("width", mp.app.output.get_size().columns)
  File "/usr/lib/python3.6/site-packages/rtichoke/interface.py", line 138, in set_option
    rcall(api.mk_symbol("options"), **kwargs)
  File "/usr/lib/python3.6/site-packages/rtichoke/interface.py", line 83, in rcall
    raise RuntimeError("R eval error.")
RuntimeError: R eval error.

I use Python 3.6.4 and the following R version on Linux (4.15.7-1 Kernel on Arch Linux)

R.version
               _                                          
platform       x86_64-pc-linux-gnu                        
arch           x86_64                                     
os             linux-gnu                                  
system         x86_64, linux-gnu                          
status         Patched                                    
major          3                                          
minor          4.3                                        
year           2018                                       
month          03                                         
day            01                                         
svn rev        74341                                      
language       R                                          
version.string R version 3.4.3 Patched (2018-03-01 r74341)
nickname       Kite-Eating Tree 

rtichoke_eshell

library(rgdal) crashes rtichoke

My system is Ubuntu 17.10.

If I do library(rgdal) or load any library that has rgdal as a dependency, rtichoke first gives:

r$> library(rgdal)
Loading required package: sp
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...
):
 unable to load shared object '/home/miles/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgda
l.so':
  /usr/lib/libgdal.so.20: undefined symbol: sqlite3_column_table_name

And then will segfault on any further attempt:

r$> library(rgdal)

 *** caught segfault ***
address 0x25e6e6, cause 'memory not mapped'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(lib, package, package.lib)
 3: loadNamespace(package, lib.loc)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package,lib.loc)    env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return)         message(paste("Error:", msg), domain = NA)   else stop(msg, call. = FALSE, domain = NA)})
 8: library(rgdal)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Selection: 2
Segmentation fault (core dumped)

If I use the regular R console, it works normally:

> library(rgdal)
Loading required package: sp
rgdal: version: 1.2-16, (SVN revision 701)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.2.1, released 2017/06/23
 Path to GDAL shared files: /usr/share/gdal/2.2
 GDAL binary built with GEOS: TRUE
 Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.2-5

My Googling has turned up this issue, which I think is related, but you may be a better judge than I: https://gis.stackexchange.com/questions/72530/gdal-loads-in-python-but-not-ipython-linux

Is there a nowrap option?

I am using rtichoke with neovim terminal and it would be great to have a way to let DataFrame output write beyond the border of the terminal without wrapping so all variables stay in their own columns. I am hoping for something similar to the output of dbext if you have ever used that vim plugin.

Thanks so much for building rtichoke btw. I can't believe it has taken me this long to find it.

Objects sent to console via SendCode are not displayed without user input.

Apologies if that headline is unclear. I'm having trouble succinctly explaining this issue.

Since v.0.1.4, I've noticed that sending an object to the rtichoke console (using SendCode in ST3) does not follow up with the return key. So the text sits at the console line, waiting for additional user input.

For example, sending x to the console will not display the contents of x automatically. Sending print(x), however, works just fine. This is a bit of a hassle if you just want to see an object's contents without bouncing between windows.

This behavior is present in rtichoke in TerminalView and iTerm. I just downgraded to rtichoke v0.1.3 and can confirm that this was not happening in that version.

Nvim-R: Usage: rice^@^@rice: error: no such option: --no-save^@

Hey,

I understand that there is only partial support for Nvim-R, but I thought I'd report this issue.

After setting let R_app = 'rice', I get this error message when trying to start Nvim-R with an R file open:

Usage: rice^@^@rice: error: no such option: --no-save^@

I tried both pip install rice and pip install git+https://github.com/randy3k/rice.

I couldn't find any mentions of this error message in either rice's or Nvim-R's issues. Any idea what the issue is?

Cheers!

changelog?

would it be possible to include even a minimal changelog of changes for each tagged release?

API for custom completions

Is there (or are there plans for) an API to add custom completions?

For example, rice correctly completes package names inside a function call to library and require. This is currently hard-coded. It would be helpful for users to be able to add similar completion for other NSE calls. The conventional example is obviously dplyr but I’m more interested in this for an own package, where NSE is used to specify module imports in a very similar way to library.

For instance, the user would write

mod::use(klm

And the completion could suggest klmr/sys (which is an actual module).

In the above example the function is using NSE and the argument is hence unquoted. But of course it would also make sense to be able to provide custom completion for quoted arguments.

Expose `--no-restore-data` and `--no-save` options

As part of #10 rice now exposes some of the options, but not everything. In particular --no-restore-data and --no-save, which means that rice always restores the workspace in .RData exists, and saves it when using q(). Also the implementation of --vanilla is not quite right as it does not set these options either.

It looks like you can pass them to the R process at https://github.com/randy3k/rice/blob/257d0360b9362c0ca973249038b0b939deeaa9b5/rice/session.py#L83-L85

I was planning on sending a PR to add these, but I am not sure how you would prefer to pass the options down to the RSession class.

rice does not locate R installation

Hi there,

I followed the installation instructions and also the FAQs.

My path looks as follows:

/usr/lib/R/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

rice is installed via pip. However, when starting rice I still see:

-bash: rice: command not found.

I also tried exporting R_HOME and LD_LIBRARY_PATH.

Running Debian 9 (stretch). R 3.4.1 is installed using the backports repo (/usr/lib/R).

Any ideas?

Thanks for your work 👍

python callback attempting to attach package

issue with attaching packages

`
r$> library(tidyverse)
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\callbacks.py", line 31, in write_console_ex
output = buf.decode(ENCODING)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 44: invalid start byte

r$> library(dplyr)
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\callbacks.py", line 31, in write_console_ex
output = buf.decode(ENCODING)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 44: invalid start byte

`

here is the pip info from the install this morning:

`

pip install -U rice
Collecting rice
Downloading rice-0.0.18.tar.gz (244kB)
100% |████████████████████████████████| 245kB 1.2MB/s
Requirement already up-to-date: pygments in b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages (from rice)
Collecting six (from rice)
Downloading six-1.11.0-py2.py3-none-any.whl
Requirement already up-to-date: wcwidth in b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages (from rice)
Building wheels for collected packages: rice
Running setup.py bdist_wheel for rice ... done
Stored in directory: C:\Users\pjc\AppData\Local\pip\Cache\wheels\b0\1d\ce\0494449c54c5f7fa0bf7fc86cd2c4c5d1372ff9c85201e51e8
Successfully built rice
Installing collected packages: six, rice
Found existing installation: six 1.10.0
Uninstalling six-1.10.0:
Successfully uninstalled six-1.10.0
Found existing installation: rice 0.0.9
Uninstalling rice-0.0.9:
Successfully uninstalled rice-0.0.9
Successfully installed rice-0.0.18 six-1.11.0
`

rice crashes when X11 server connection is interrupted

I’m running rice on a server inside a tmux session. I can display plots on my local computer via X11. However, when the X11 connection is killed (because the SSH connection closes) and I subsequently re-connect to the server and my tmux session, rice has been killed — and in addition my terminal misbehaves (which can be fixed by typing reset).

R, by contrast, merely gives the following error message:

Error: X11 fatal IO error: please save work and shut down R

In addition, its dev.list() still lists the now-defunct X11cairo device. Closing that device and opening a new one works.

Here’s a step-by-step list of commands to reproduce this:

  1. local ⟩ ssh ‹some-remote-host›
  2. remote⟩ tmux new
  3. tmux  ⟩ rice
  4. rice  ⟩ dev.new()
  5. Close the SSH session
  6. local ⟩ ssh ‹some-remote-host›
  7. remote⟩ tmux attach

Result: rice has crashed with the error message shown above.

Could not run rice Windows 10

How could I fix the issue

Kind regards

C:\Users\tho>echo %R_HOME%
C:\Program Files\R\R-3.4.1

C:\Users\tho>rice
Traceback (most recent call last):
  File "c:\programdata\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Miniconda3\Scripts\rice.exe\__main__.py", line 9, in <module>
  File "c:\programdata\miniconda3\lib\site-packages\rice\__init__.py", line 41, in main
    RiceApplication().run(options)
  File "c:\programdata\miniconda3\lib\site-packages\rice\riceapp.py", line 222, in run
    rsession = RSession()
  File "c:\programdata\miniconda3\lib\site-packages\rice\session.py", line 70, in __init__
    self.libR = PyDLL(str(libR_path))
  File "c:\programdata\miniconda3\lib\ctypes\__init__.py", line 344, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Scrolling snaps back to cursor.

Hi there,

When using the latest version of rice (0.0.40) in a TerminalView window in Sublime Text 3, I'm having issues scrolling up. After about a second of scrolling, rice snaps back to the cursor. This didn't happen in 0.0.39. (My versions of TerminalView and SublimeText have not changed.)

Let me know if I can provide any other info. Thanks for a great console!

SendCode / Rice triggering python exception

Hi. Here is a simple example of the errors I am seeing.

env:

  • windows x64
  • sublime & codesend, r-box
  • rice from pip install
  • python 3.6
  • R 3.4.1

test_rice-02.R

library(feather)     
library(data.table) 

action and notes

  • select all code in file test_rice-02.R

  • ctrl-enter to send selected code

  • ctrl-enter to send the selected code a second time (to trigger error)

  • the first time I send the code, works OK

  • rice prompt looks OK, i.e. I get r$> prompt so looks like it is ready for new input

  • the second time I send the code, I get exception shown

  • I can switch to console, press enter on last library(data.table) sent and processes OK

Trying different combinations of sending code can crash rice/conemu completely requiring me to kill process.

I have tried the same scenario plan R console and no issues.

Once I get the exception from the SendCode to rice scenario it is possible, but intermittently, to get same exception by just directly executing code in rice, i.e. without any SendCode use. However, haven't been able to get same exception by just starting a clean rice session and interacting directly with it, i.e. never use SendCode.

conemu/rice console output:
this is the output from new clean rice session and using SendCode from sublime as described above

[rice] [R] [java] D:\wspace\rice-eg > rice
R version 3.4.1 (2017-06-30) -- Single Candle
Platform: x86_64-w64-mingw32


r$> library(feather)

r$> library(data.table)
data.table 1.10.4
  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
  Release notes, videos and slides: http://r-datatable.com

r$> library(feather)


Unhandled exception in event loop:
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\eventloop\coroutine.py", line 79, in step_next
    new_f = coroutine.throw(exc)
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\buffer.py", line 1550, in new_coroutine
    yield From(coroutine(*a, **kw))
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\eventloop\coroutine.py", line 81, in step_next
    new_f = coroutine.send(f.result())
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\buffer.py", line 1425, in async_completer
    completions = list(completions)
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\completion.py", line 34, in get_completions
    app = get_app()
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\application\current.py", line 47, in get_app
    return DummyApplication()
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\application\dummy.py", line 18, in __init__
    super(DummyApplication, self).__init__(output=DummyOutput(), input=DummyInput())
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\application\application.py", line 208, in __init__
    mouse_support=mouse_support)
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\renderer.py", line 269, in __init__
    self.reset(_scroll=True)
  File "b:\python\anaconda3_4.3.1\envs\rice\lib\site-packages\rice\deps\prompt_toolkit\renderer.py", line 293, in reset
    self.output.scroll_buffer_to_prompt()

Exception 'DummyOutput' object has no attribute 'scroll_buffer_to_prompt'
Press ENTER to continue...r$> library(data.table)
Press ENTER to continue...
r$> library(data.table)

Auto completion is laggy

This may just be due to the number of packages I have installed, but using R interactively with rtichoke is quite laggy at the moment. It takes 4-5 seconds to search for completions as I type out a function name.

I'm not sure how indexing is being accomplished currently, but maybe searching only attached packages or individual namespaces when "package::xx" is entered would be more efficient if it's not already being done.

This is an awesome concept though. I admire all of your hard work!

Autocomplete to include parentheses?

Any way to set in the settings that autocomplete finishes function calls by providing the () at the end of a function name? I'm so used to having this feature that it always causes bugs in my code when working with rice

Permission and lib paths

I have some troubles with permissions.

After installation my already installed packages are not found, because my user library is not in the path
.libPaths(). The libraries that are in .libPaths() are not writeable and when I try to create add my user library via .libPaths(new = "/home/username/...") within rice, nothing happens.

Any suggestions?

reticulate mode

it may be useful to have more interactions with the python shell via the use of reticulate.

line buffering on stdout

If you define a function which prints to stdout, rice buffers the output per line. In the following case foo is never printed to the screen in rice.

f <- function() {
  cat("foo")
  Sys.sleep(1)
  cat("\rbar")
}

If you explicitly print to stderr (which is unbuffered) foo does print.

f <- function() {
  cat("foo", file = stderr())
  Sys.sleep(1)
  cat("\rbar", file = stderr())
}

If you run these two functions in the standard R console foo is printed in both cases.

This was using rice version 0.0.14

Turn off package completions in calls

When I am completing a functions arguments in a call I typically do not want to see the package completions as well. e.g. the last few completions in this screenshot.

screenshot 2017-12-04 11 40 53

For summary() there are a lot of arguments, but for many functions there are only a few and the completions are dominated by package completions (which are usually not useful in this context).

An option to suppress package completions entirely, or turn them off for this case would be great!

not compatible with libzmq shipped by pbdZMQ

For some reasons, rtichoke fails to load libzmq because libzmq cannot find libR,

Error: package or namespace load failed for ‘pbdZMQ’:
 .onLoad failed in loadNamespace() for 'pbdZMQ', details:
  call: fun(libname, pkgname)
  error: Could not load  /Library/Frameworks/R.framework/Versions/3.4/Resources/library/pbdZMQ/libs/libzmq.5.dylib : Error in dyn.load(dn.file, local = FALSE) :
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/pbdZMQ/libs/libzmq.5.dylib':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/pbdZMQ/libs/libzmq.5.dylib, 10): Symbol not found: _R_registerRoutines
  Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/pbdZMQ/libs/libzmq.5.dylib
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.4/Resources/library/pbdZMQ/libs/libzmq.5.dylib

A solution is to use DYLD_INSERT_LIBRARIES (macOS) or LD_PRELOAD (Linux)

env DYLD_INSERT_LIBRARIES=/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libR.dylib rtichoke
env LD_PRELOAD=<PATH TO libR.dylib> rtichoke

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.