Killing "+" sign after incorrect syntax [duplicate] - r

This question already has answers here:
ending "+" prompt in R
(5 answers)
Closed 6 years ago.
After entering a complex code(where something was incorrect), instead of > sign R displays +. If I knew what is missing (oftentimes due to missing out (,),') it would be easy to fix, but I am not sure. Therefore I am "locked" with this + state and cannot escape it. Is there a way to kill it and revert back to the default prompt?

It depends on where R is running. Try CTRL+C on the keyboard, if you are running plain R. Some IDE (like RStudio) have a Stop button you can press to abort the command given.

Often Esc, the escape key works.

Related

How to Stop an Endless String in R [duplicate]

This question already has answers here:
ending "+" prompt in R
(5 answers)
Closed 6 years ago.
I'm new to R Programming and have somehow gotten stuck in an argument that will not stop. I wrote view(file) and hit enter and now there is an endless string of "+" and the argument will not close. Any help would be appreciated on how to close my argument. I know I can just force quit the program, but I would rather just figure out of to end the argument. Thank You!
In R, if you keep seeing an endless string of +, it means that you didn't close a pair of either single quotes '', double quotes "", or parentheses/brackets ()/{}.
Usually, not closing a pair of parentheses or brackets produces an error sooner or later. But open quotes can keep going forever if you do not close them (or unless you terminate the command: esc in RStudio or ctrl+c if in command line).
Here is an example:
> view("file
+ i can keep
+ writing
+ until
+ i close the
+ double quote
+ , but once I do,
+ I have to also close the parentheses )
+ "
+ )
Error: could not find function "view"
>

Rstudio: Setting TO DOs [duplicate]

This question already has answers here:
TODO comments in rStudio
(4 answers)
Closed 5 years ago.
How do I use TO DOs in RStudio? By TO DOs I mean, some special flags or comments that would stand out, so I could get back to certain things I want to rework/modify etc.
I searched on Internet as well as on Rstudio, but I don't seem to be able to find such a functionality as other IDEs have (e.g. PyCharm when I code in python). I am using comments currently, but that is very imperfect in a bigger project that is heavily commented anyway.
Can you share your tips and tricks?
Ctrl + Shift + R to create a section label that stands out. Any code that sits between this and another section label can be minimized/maximized when you need to, and you can call it TO DO.
You can also use Alt + Shift + J to jump between these section labels when you want to rework or modify them.
The answer to this question might help, I suppose.
I am not sure if it is okay to copy the full text of that answer, so briefly:
Shift + Cmd + F / Shift + Ctrl + F
enter ^\s*# TODO:
^ means the start of the string we are interested in,
\s is for any whitespace character (space, tab, line break),
and the following * implies that the whitespace character is repeated zero to an infinite amount of times;
a-a-and – run the search!

"more" like command in R console [duplicate]

This question already has answers here:
Equivalent to unix "less" command within R console
(5 answers)
Closed 8 years ago.
Is there any command in R console which behaves same as "more" command in Linux?
Consider this
>x=list(seq(100000), seq(100000))
>x
It displays everything at one go and shows message at the end "reached getOption("max.print")". Scrolling back to top doesn't show me the first values. I need a command like more(x) which will show more and more by pressing space bar.
Would ?page do the trick? e.g., page(list(a = rnorm(1000), b=rnorm(1000)))

Disable underscore "_" shortcut inserting "<-" in Vim R plugin [duplicate]

This question already has answers here:
Vim: underscore(_) automatically converted to (<-)
(4 answers)
Closed 8 years ago.
By default, the Vim-R-plugin inserts <- whenever I type or paste an underscore _. This creates problems when I paste stuff like geom_bar, which becomes geom <- bar. Is there a way to turn this short-cut off?
I tried looking at the manual (scroll down to Edit section) but couldn't figure out how to do it.
I'm using Vim-R-plugin Version 0.9.9.9
for Vim version 7.4.
From the help page of the plugin:
6.3. Assignment operator and Rnoweb completion of code block
...
To completely disable this feature, put in your vimrc:
let vimrplugin_assign = 0
--
EDIT: As of writing this (2019-10-25), add this to your vimrc instead:
6.4. Assignment operator and Rnoweb completion of code block
...
let R_assign = 0

paste character limit [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Why and where are \n newline characters getting introduced to c()?
I am running R (version 2.15.1) in a bash shell (version 4.2.36(1)) in the GNOME terminal (version 3.4.1.1). Sometimes I write my code in a text file and then paste it directly into the console (when running R). I didn't have any problems until the scripts I was pasting grew in length. Now, it appears that any code greater than 4206 characters (including \n) is rejected (i.e., the first 4206 characters are accepted and the remaining code is truncated; the truncation is accompanied by the terminal "bell" sound). This character limit is not specific to bash or GNOME terminal because I do not observe a character limit when pasting into e.g., vi. Therefore, I suspect that the character limit is imposed by R, but do not know how to change it, assuming it is a user-configurable parameter. Can the paste limit be changed and if so, what parameter governs it?
It looks like you're running into a known limitation of the console. As it says in Section 1.8 - R commands, case sensitivity, etc. of An Introduction to R:
Command lines entered at the console are limited[3] to about 4095 bytes (not characters).
[3] some of the consoles will not allow you to enter more, and amongst those which do some will silently discard the excess and some will use it as the start of the next line.
Either put the command in a file and source it, or break the code into multiple lines by inserting your own newlines at appropriate points (between commas).
The value is hard-coded in src/include/Defn.h : #define CONSOLE_BUFFER_SIZE 4096, so you would need to recompile R to change it.

Resources