I generally use R from the command line. However, this problem has been annoying me. When I use the up arrow to get a previous command, if that command was multiple lines, then R only shows the last line (although if I execute the command, it executes the whole thing).

Any ideas about what setting I need to change to make this work as expected?

  • To complicate things, this doesn't always happen, and I haven't yet figured out in which situations it occurs – Jeremy Apr 25 '14 at 19:08
  • Can you specify wider what do you mean with work as expected? The input and the history management of R seems to be deeply related with the use of readline when it is built with it. It is reported by the R help that it can behave in different ways from different environments. Did you refer to something like the effect that shopt -s cmdhist or -u has on the bash history? Please add information about the version of R and of your environment (echo $BASH_VERSION, if you run from konsole, xterm...) so it will be possible to start to write a table of behaviours. – Hastur Jun 17 '14 at 8:16
  • @Jeremy: I too have observed this "bug" with several versions of R. Not only the history is truncated but new lines of code copy pasted into the terminal will also appear truncated making it very difficult to modify them in the terminal after pasting. And moving upwards with the arrow key to call previous lines might even "erase" previous lines of code or results displayed. And move upward the line were one is writing at their place. But as Jeremy explained it is only a display problem. Pressing enter runs the code line properly. – Prolix Jun 24 '15 at 9:01
  • I believe this question belongs on Stack Overflow. It doesn't have much to do with Ubuntu. – Gx1sptDTDa Jul 19 '15 at 11:53
  • I guess I know what you mean: sometimes the terminal can be confused, often after resizing window. Being on the bash prompt you can often reset the terminal with the command 'reset' or echo <ctrl-v> <escape> <c> (echoes a literal escape c sequence). I did not find a way for R commandline, though. Stopping (<ctrl-z>) and resetting does not help. – MoreIT Jul 22 '15 at 7:56

See https://stackoverflow.com/questions/16226216/r-command-history-how-to-configure-up-arrow-to-treat-multiline-brace-enclosed

For instance

f <- function(x) # press Ctrl+v Ctrl+j NOT shift+enter

What you are looking for is not possible in my understanding using the R terminal from bash

  • I do not think that it was what Jeremy was referring to. This would not behave "properly" when pressing enter as described in the question. – Prolix Jun 24 '15 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.