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

Muenchen, Robert A (Bob) muenchen at utk.edu
Mon Mar 7 15:52:54 CET 2011


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. Is there a reason I should avoid it?

Thanks,
Bob

=========================================================
  Bob Muenchen (pronounced Min'-chen), Manager  
  Research Computing Support
  Voice: (865) 974-5230  
  Email: muenchen at utk.edu
  Web:   http://oit.utk.edu/research, 
  News:  http://oit.utk.edu/research/news.php
========================================================



More information about the R-help mailing list