Re: [R] When to quote a package name

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Mon, 10 Mar 2008 19:47:15 +0100

Muenchen, Robert A (Bob) wrote:
> Dear HelpeRs,
>
> I'm confused about the role of quotes around package names on the
> library and detach functions. Books on R use both approaches:
>
> library(Hmisc)
> describe(mydata)
> detach(package:Hmisc)
>
> and
>
> library("Hmisc")
> describe(mydata)
> detach("package:Hmisc")
>
> The help file for detach says "quoted or unquoted" and the help file for
> library says about the package, "the name of a package, given as a name
> or literal character string, or a character string, depending on whether
> character.only is FALSE (default) or TRUE)."
>
> Are there conditions under which it matters? Which is best?
>

The cleaner approach is to use quotes. I'd expect

x <- "Hmisc"
library(x)

to install package "Hmisc", but not package "x"... In fact, it also installs "x" (as documented), unfortunately.

Uwe Ligges

> Thanks,
> Bob
>
> =========================================================
> Bob Muenchen (pronounced Min'-chen),
> Manager, Statistical Consulting Center
> U of TN Office of Information Technology
> Stokely Management Center, Suite 200
> 916 Volunteer Blvd., Knoxville, TN 37996-0520
> Voice: (865) 974-5230
> FAX: (865) 974-4810
> Email: muenchen_at_utk.edu
> Web: http://oit.utk.edu/scc
> Map: http://www.utk.edu/maps
> news: http://listserv.utk.edu/archives/statnews.html
> =========================================================
>
> ______________________________________________
> 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.



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. Received on Mon 10 Mar 2008 - 18:52:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 10 Mar 2008 - 20:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive