Tim
Tim

Reputation: 99408

Getting help on R command line window

I wanted to get help about repeat in R command line window. But

> ?repeat  
+   
> help(repeat)  
Error: unexpected ')' in "help(repeat)"  

repeat seems different from other functions. Also I found even for if, I also cannot get help document. So I assume help is just for non control-follow function/command? How to get the help document about control flow commands then?

Thanks!

Upvotes: 7

Views: 7998

Answers (2)

Gavin Simpson
Gavin Simpson

Reputation: 174788

repeat, for, etc are parts of the language that the parser gives high priority to; in this case R thinks you were going to write something it needed to evaluate before calling the function ?() on the result. The canonical solution is to quote the function name using backticks:

?`repeat`

As DWin notes above, this can be used for any function name. Backticks are also useful for quoting objects or components of lists/data frames that have non-standard names.

Upvotes: 7

aL3xa
aL3xa

Reputation: 36080

help("repeat")

?"repeat"

Upvotes: 6

Related Questions