How to Stop an Endless String in R [duplicate] - r

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"
>

Related

Why it is unable to write \delta inside a print command in "R"? [duplicate]

This question already has answers here:
Error: '\R' is an unrecognized escape in character string starting "C:\R"
(5 answers)
R - Unable to replace unrecognized escape symbol "\&" in character string
(1 answer)
Closed 24 days ago.
I want to insert a delta inside a print command in R. Expect \delta all the greek letters are coming without any error. However, the following error is prompted when trying to print \delta using the sprintf command. Can you help?
I tried searching for an answer and found one. But the solution was to use a forward slash which obviously won't work in my case.

Creating a string in R with " in it [duplicate]

This question already has an answer here:
paste quotation marks into character string, within a loop
(1 answer)
Closed 5 years ago.
I am trying to get text given between “ ” to make a string. But because string has two “ already in it, I am not able to do so.
?jql=filter%20=%20"Plan%20Standup%20-%20Mutual-SA"
When I am trying to input , it is giving me an error.
Input <- "?jql=filter%20=%20"Plan%20Standup%20-%20Mutual-SA""
I tried many escape characters, but always I got an error message.
Error: unexpected symbol in "input <- "?jql=filter%20=%20"Plan"
any help will be highly appreciated
In the string, there is already a double quote. So, we can wrap it with single quotes
Input <- '?jql=filter%20=%20"Plan%20Standup%20-%20Mutual-SA'
cat(Input, "\n")
#?jql=filter%20=%20"Plan%20Standup%20-%20Mutual-SA
"Escape" the character like this
a <- "\""

What does the "+" symbol mean on the left side of the R console?

I have entered in code to plot a graph, but when I press Enter to execute the graph, it does not plot the graph. Rather, + symbols appear every time I press Enter to execute the command and plot the code.
Now there is a long column of + symbols in my R consoles.
Why is this happening and what can I do to prevent this from happening?
The prompt has + because it signifies that the prompt is expecting more from the line of code, a sort of continuation. This may be because you forgot to close something so the prompt expects the closing side. For example, say you forgot to close a string like so:
> "
+
+
Here, I entered a double-quote into the prompt and kept on pressing Enter. There is a missing double-quote to tell the prompt I've ended the string literal, so the prompt expects another double-quote. Once you enter the double quote the prompt will stop expecting it. For example:
> "
+
+ "
[1] "\n\n"
This is standard on all command prompts, to expect more code if something isn't ended properly, like the string literal above. Check your code to make sure you've closed all opening quotes, symbols, etc, so the prompt doesn't expect it and your code executes correctly.
The ways of exiting the prompt when this happens are:
Esc on RGui and RStudio
Ctrl-C on Terminals and Command Prompts
This could happen if you used space in the middle of an object name, eg. Column names. R doesn't allow space in between " ".

Killing "+" sign after incorrect syntax [duplicate]

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.

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!

Resources