" prompt I get a "+" prompt. I appear to be stuck in..." /> " prompt I get a "+" prompt. I appear to be stuck in..." /> " prompt I get a "+" prompt. I appear to be stuck in..."/>

ending "+" prompt in R

122.5k views Asked by At

I'm fairly new to R and I made a type-o while entering some code and now instead of getting the ">" prompt I get a "+" prompt. I appear to be stuck in some kind of function that is looking for input, but I can't seem to get out of it. I figure that there must be a better way to fix this problem then closing R and rerunning my script but I haven't been able to find anything on google (likely because I don't know the right search terms).

Thanks for your help, sorry it's a trivial question

The code I entered was as follows:

> fit = lm(x~`y)
+ fit = lm(x~y)
+ fit
+ summary(fit)
+ 
+ 
+ end
+ ;
+ break
+ )
+ 
+ 
+ 
+ 
    
    
+ 
    
+ quit()
+ 
+ quit
+ break()
+ abline(b0hat,b1hat)
+ return(null)
+ 
5

There are 5 answers

7
Konrad Rudolph On BEST ANSWER

It depends on how you’re running R.

In the terminal, the “normal” way is Control+C – the “cancel” key combination.

In the graphical R application and in RStudio, it’s Escape.

0
TMin On

IShouldBuyABoat was right the problem was that I accidentally included a back tick, this caused the parser to require a second back tick to close the string before evaluating the string or returning the proper prompt.

I used Escape key as suggested by Konrad Rudolph, although I was not in R studio and this returned the prompt.

Thanks for all the help, and sorry I didn't post my answer earlier. This is my first question and I didn't realize that I was supposed to do that.

1
Pramodya Abeysinghe On

If you are using terminal you can quit using q()

0
angryip On

I had a similar problem when "copy/pasting" large quantities of text into the R prompt. I would see a dangling "+" at the end. However, when individually selecting blocks of executable code and pasting sequentially, the "+" would not appear. I ended up loading the entire file in the terminal to solve the problem:

source("myfile_with_lots_of_text.r")
1
Amir On

I am using RStudio 3.3.1 and had a the same problem. Press Escape key for worked. Please try this and let me know if I can help more...