I am trying to use datasets within R with a loaded package, for example, MASS. When I use the dataset phones, it can be done using data(phones, package=?MASS?). I am thinking about an alternative but more flexible way to load this dataset. Because phones is the 70th dataset in this package, I wrote the following codes. Unfortunately they don?t work. It will be greatly appreciated if someone can help me figure out. alldata = data(package="MASS") arg = alldata$results[70,3] ineed <- data(arg, package="MASS")
Perhaps something like get(data(list = arg)) 2012/3/29 Hua Liang <dickliang911 at gmail.com>:> > I am trying to use datasets within R with a loaded package, for example, MASS. When I use the dataset phones, it can be done using data(phones, package=?MASS?). I am thinking about an alternative but more flexible way to load this dataset. Because phones ?is the > 70th dataset in this package, I wrote the following codes. Unfortunately they don?t work. It will be greatly appreciated if someone can help me figure out. > > alldata = data(package="MASS") > arg = alldata$results[70,3] > ineed <- data(arg, package="MASS") > ______________________________________________ > 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.
On Mar 29, 2012, at 12:13 PM, R. Michael Weylandt wrote:> Perhaps something like>> alldata = data(package="MASS") >> arg = alldata$results[70,3] >> ineed <- data(arg, package="MASS") > > get(data(list = arg))I think the get() is superfluous: > rm(phones) > exists("phones") [1] FALSE > data(list=arg, package="MASS") > exists("phones") [1] TRUE> > 2012/3/29 Hua Liang <dickliang911 at gmail.com>: >> >> I am trying to use datasets within R with a loaded package, for >> example, MASS. When I use the dataset phones, it can be done using >> data(phones, package=?MASS?). I am thinking about an alternative >> but more flexible way to load this dataset. Because phones is the >> 70th dataset in this package, I wrote the following codes. >> Unfortunately they don?t work. It will be greatly appreciated if >> someone can help me figure out. >>-- David Winsemius, MD West Hartford, CT