[R] Teaching R: To quote, or not to quote?

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Mar 7 17:58:21 CET 2011



On 07.03.2011 16:17, Duncan Murdoch wrote:
> On 07/03/2011 9:52 AM, Muenchen, Robert A (Bob) wrote:
>> Hi All,
>>
>> When I teach an intro workshop on R, I've been minimizing "quote
>> confusion" by always using quotes around package names in function
>> calls. For example:
>>
>> install.packages("Hmisc")
>> update.packages("Hmisc")
>> library("Hmisc")
>> citation("Hmisc")
>> search() # displays package names in quotes
>> detach("packages:Hmisc") # just as search displayed it
>>
>> all look consistent with quotes. They're optional, of course, with
>> library and detach and I tell them that. But for beginners, it's hard
>> to remember when they don't need quotes. This perspective continues
>> with function names in help:
>>
>> help("mean")
>> ?"mean"
>> help("if")
>> ?"if"
>>
>> which avoids the fact that some important topics like control-flow
>> words (e.g. help(if) ) generate error messages without the quotes. For
>> help, the quotes make the string a "topic" instead of a name, but that
>> doesn't seem to block it from finding function names in quotes.
>>
>> I'm about to go to press with the second edition of R for SAS and SPSS
>> Users& I'm wondering if there's a downside to this. No other books
>> I've seen use library("package") or help("function") consistently.

I hope at least my German / Japanese one does (but I'd need to parse it 
myself).

As you said, it is more consistent to use quotes here and over the 
years, I tried to change all my course material to show versions with 
quotes only.

Uwe


> Is
>> there a reason I should avoid it?
>
>
> The only reasons I can think to avoid that recommendation is that people
> might find typing unnecessary quotes to be irritating and they might be
> confused when they see unquoted usage elsewhere. Those aren't
> particularly strong reasons...
>
> Duncan Murdoch
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list