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 ========================================================
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. 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
>>> Duncan Murdoch <murdoch.duncan at gmail.com> 03/07/11 3:17 PM >>> >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. >> ... I'm wondering if there's a downside to this. > >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...Agreed, especially for library and the like where . But from a user perspective most of the advantage of ?mean and ??mean over help("mean") is the reduction in typing - especially the utility of things like only typing the ? in ?rnorm(q=23) after "Error in rnorm(q = 23) : unused argument(s) (q = 23)". That is so useful that I'd say it's worth reinforcing by using ? without quotes where possible. ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
On 3/7/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 >FWIW, the style for JSS now enforces (via Achimitization) the use of quotes as you show above. -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
Oh, JSS... I was Achimitized last week... although I have been seeing library() calls without double quotes almost everywhere. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Tue, Mar 8, 2011 at 7:34 AM, Michael Friendly <friendly at yorku.ca> wrote:> On 3/7/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 >> > > FWIW, the style for JSS now enforces (via Achimitization) the use of quotes > as you show above. > > -Michael > > > -- > Michael Friendly ? ? Email: friendly AT yorku DOT ca > Professor, Psychology Dept. > York University ? ? ?Voice: 416 736-5115 x66249 Fax: 416 736-5814 > 4700 Keele Street ? ?Web: ? http://www.datavis.ca > Toronto, ONT ?M3J 1P3 CANADA > > ______________________________________________ > 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. >