[Rd] index.search
Adrian Dușa
dusa.adrian at unibuc.ro
Mon Jun 16 05:23:26 CEST 2014
Hi Gabriel,
Actually, I am not going to use multiple versions of the same package,
but always the last version. What I would like to do is:
- to run all examples from all functions in the package, saving the
results into a list
- compare the list to an already saved one (from the previous version
of the package), possibly using all.equal()
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.
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).
Best wishes,
Adrian
On Mon, Jun 16, 2014 at 5:46 AM, Gabriel Becker <gmbecker at 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.adrian at 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 at 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
More information about the R-devel
mailing list