On Sun, Jun 15, 2014 at 8:23 PM, Adrian DuÈa <dusa.adr...@unibuc.ro> wrote:
> Hi Gabriel, > > <snip> > I tried using the example() function, like this: > example("deMorgan", package="QCA", give.lines=TRUE) > > That returns the commands from the examples section, but if a command > is split over multiple rows I cannot use it automatically. > You can. This is valid R source, so the parser will understand it expr = parse(text= example("deMorgan", package="QCA", give.lines=TRUE)) You can then evaluate some or all of that expression using either R's own eval package or, e.g. Hadley Wickham's evaluate package (for your particular usecase evaluate will be easier I think). > > I could also use: > capture.output(example("deMorgan", package="QCA", ask=FALSE)) > > That would indeed work for the printed output, but I would also like > to compare the objects saved by the deMorgan() function. If that is > not possible, I'll probably be happy with the printed output. > > I'd still be curious as to why the index.search() function cannot be > used... (it seems useful for other purposes). > index.search is an unexported function, which means that it is subject to change in how it behaves without notice or even externally available reasons. You can get it via :::, but again, it's really not the right tool here, and not safe to use in general in code you expect to keep working. HTH, ~G > > Best wishes, > Adrian > > > On Mon, Jun 16, 2014 at 5:46 AM, Gabriel Becker <gmbec...@ucdavis.edu> > wrote: > > Adrian, > > > > R isn't really designed to use multiple versions of the same package in > the > > same R session. To do what you want you'll need to unload one version of > the > > package before you load the next, which will work some percentage of the > > time between 50 and 100 ("usually"), but when it can be done it is > > relatively easy to do. > > > > Packages with C code will give you problems, or at least they used to. I > > haven't tried recently. See Prof Ripley's response here: See > > https://stat.ethz.ch/pipermail/r-devel/2009-February/052229.html > > > > For packages that can be unloaded/reloaded safely, is there a reason you > > can't just use the existing example function with two different library > > locations (lib.loc argument) with the two package versions installed? > > > > ~G > > > > > > On Sun, Jun 15, 2014 at 6:22 PM, Adrian DuÈa <dusa.adr...@unibuc.ro> > wrote: > >> > >> Dear r-devel, > >> > >> I am trying to automatically check if two successive versions of a > >> package have the same results (i.e. code not broken), by parsing the > >> example sections for each function against a previously tested > >> version. > >> > >> While trying to replicate the code from example(), I am facing an > >> error related with te "index.search" function (line 7 in the example() > >> code). > >> This is the code I am using: > >> > >> example2 <- function (topic, package = NULL, lib.loc = NULL, > >> character.only = FALSE, > >> give.lines = FALSE, local = FALSE, echo = TRUE, verbose = > >> getOption("verbose"), > >> setRNG = FALSE, ask = getOption("example.ask"), prompt.prefix = > >> abbreviate(topic, 6), run.dontrun = FALSE) > >> { > >> if (!character.only) { > >> topic <- substitute(topic) > >> if (!is.character(topic)) > >> topic <- deparse(topic)[1L] > >> } > >> pkgpaths <- find.package(package, lib.loc, verbose = verbose) > >> file <- index.search(topic, pkgpaths, TRUE) > >> return(file) > >> } > >> > >> > example2("deMorgan", package="QCA") > >> Error in example2("deMorgan", package = "QCA") : > >> could not find function "index.search" > >> > >> > >> I've tried an explicit library(utils), with the same result. > >> ?index.search doesn't yield anything better... > >> > >> Could anyone point me in the right direction, please? > >> Thank you, > >> Adrian > >> > >> > >> -- > >> Adrian Dusa > >> University of Bucharest > >> Romanian Social Data Archive > >> 1, Schitu Magureanu Bd. > >> 050025 Bucharest sector 5 > >> Romania > >> Tel.:+40 21 3126618 \ > >> +40 21 3120210 / int.101 > >> Fax: +40 21 3158391 > >> > >> ______________________________________________ > >> R-devel@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > > > > > > -- > > Gabriel Becker > > Graduate Student > > Statistics Department > > University of California, Davis > > > > -- > Adrian Dusa > University of Bucharest > Romanian Social Data Archive > 1, Schitu Magureanu Bd. > 050025 Bucharest sector 5 > Romania > Tel.:+40 21 3126618 \ > +40 21 3120210 / int.101 > Fax: +40 21 3158391 > -- Gabriel Becker Graduate Student Statistics Department University of California, Davis [[alternative HTML version deleted]]
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel