-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Dirk and Steve,

Dirk Eddelbuettel wrote:
> Hi Ben,
> 
> On 30 January 2009 at 14:04, Ben Goodrich wrote:
> | -----BEGIN PGP SIGNED MESSAGE-----
> | Hash: SHA1
> | 
> | Package: r-base-core-ra
> | Version: 1.2.4-1
> | Severity: normal
> | 
> | Hi Dirk,
> | 
> | In a Ra session,
> | 
> | help(matrix) # -> No documentation for 'matrix' in specified packages
> 
> Right. 
> 
> I kinda expect you to have a parallel R installation and look it up there.
>  
> | The issue is that my .libPaths() is
> | 
> | [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
> | [3] "/usr/lib/Ra/lib/R/library"     "/usr/lib/R/library"
> | 
> | so help(), by default, looks in /usr/lib/Ra/lib/R/library (which
> | apparently does not have working help pages) before it looks in
> | /usr/lib/R/library . Thus,
> |
> | help(matrix, lib.loc = .libPaths()[-3])
> 
> Interesting!
>  
> | yields the expected behavior, and help() works when lib.loc is
> | unspecified if the function you are looking for is in a package
> | contained in /usr/local/lib/R/site-library or /usr/lib/R/site-library .
> | 
> | Looking at the directories ...
> | 
> | bgoodr...@room320:~$ ls /usr/lib/Ra/lib/R/library/base
> | CITATION  demo  DESCRIPTION  man  Meta  po  R
> | 
> | bgoodr...@room320:~$ ls /usr/lib/R/library/base
> | CITATION  CONTENTS  demo  DESCRIPTION  help  html  INDEX  latex  man
> | Meta  po  R  R-ex
> | 
> | it looks like the core packages are not really "installed" by Ra, which
> | perhaps is an intentional aspect of the way the sources of R and Ra are
> 
> Correct. To keep the package smaller and to not install identical files (of a
> large size when aggregated) a second time, I aim for a minimal install. Eg no
> help pages.
> 
> Note that the _code_ is of course there as Ra patches it. There is
> /usr/lib/Ra/lib/R/library/base/R/ 
> 
> Hence I am not sure what you mean by 
> 
>   "the core packages are not really "installed" by Ra"
> 
> | overlayed. If so, then we could probably workaround this problem in
> | several ways (massive symlinkage, patch help() and example() to not look
> | in /usr/lib/Ra/lib/R/library , reorder .libPaths() after the core
> | packages are loaded, etc.), but I am not sure what would be best.
> 
> Unfortunately, I am not likely to have enough time to polish Ra ad infinum for
> such aspects. I was hoping to do users like yourself (and myself) a favour by
> packaging it. So this is of severity "wishlist" with tag "wontfix" from my
> point of view.  
> 
> If you can cook up a small patch that sets .libPaths() to the three parts
> from R, I'd be happy to take it.  Alternatively, we could decide that we are
> in favour of wasting more disk space and build the help (at least in the
> internal form).  But I'm sure someone will then complain that the html help
> is missing ...
> 
> Ra is not meant a replacement for R, but rather a complement which is why it
> has a Recommends on r-base-core.
> 
> Ok?
> 
> Dirk

The three attached patches apply to files in

/r-base-core-ra-1.2.4/src/library/utils/R

Poking around in the R code for help(), example(), and help.search(),
when lib.loc is NULL, it is ultimately changed to the output of
.libPaths(), which causes Ra trouble because the help files in the core
libraries are not built. So, in each case, when lib.loc is NULL, we
change it to the output of .libPaths() earlier and then exclude the
directory where the core libraries live.

Does this feature / bug afflict other platforms? If so, the patches
should still work, but I only tested them under Debian. E.g.

?matrix
example(matrix)
library(jit)
?jit
example(jit)
help.search("jit")

are all now working correctly under Ra with these three patches.

Thanks,
Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkmDj6QACgkQzQDSXIcN85mO7ACdGpdGSAnNPjPIKxtAbB2bUoHE
WCQAn0mqSkTOk7CzFZJyEAA0jTysSE4C
=GM2W
-----END PGP SIGNATURE-----
--- r-base-core-ra-1.2.4/src/library/utils/R/example.R	2008-09-21 18:05:11.000000000 -0400
+++ example.R	2009-01-30 17:09:56.000000000 -0500
@@ -23,7 +23,14 @@
     topic <- substitute(topic)
     if(!is.character(topic))
 	topic <- deparse(topic)[1]
-    INDICES <- .find.package(package, lib.loc, verbose = verbose)
+
+    ## default behavior would otherwise be suboptimal under Ra
+    LibPaths <- .libPaths()
+    RaLib <- dirname(system.file(package = "base"))
+    GoodPaths <- LibPaths[LibPaths != RaLib]
+
+    INDICES <- .find.package(package, verbose = verbose,
+                            lib.loc = if(is.null(lib.loc)) GoodPaths else lib.loc)
     file <- index.search(topic, INDICES, "AnIndex", "R-ex")
     if(file == "") {
 	warning(gettextf("no help file found for '%s'", topic), domain = NA)
--- r-base-core-ra-1.2.4/src/library/utils/R/help.search.R	2008-09-21 18:05:11.000000000 -0400
+++ help.search.R	2009-01-30 18:13:51.000000000 -0500
@@ -72,8 +72,12 @@
 	stop("do not know what to search")
     }
 
-    if(is.null(lib.loc))
-	lib.loc <- .libPaths()
+    if(is.null(lib.loc)) {
+        LibPaths <- .libPaths()
+        RaLib <- dirname(system.file(package = "base"))
+        GoodPaths <- LibPaths[LibPaths != RaLib]
+        lib.loc <- GoodPaths ## otherwise suboptimal behavior under Ra
+    }
 
     if(!missing(help.db))
 	warning("argument 'help.db' is deprecated")
--- r-base-core-ra-1.2.4/src/library/utils/R/help.R	2008-09-21 18:05:11.000000000 -0400
+++ help.R	2009-01-30 16:36:38.000000000 -0500
@@ -63,7 +63,14 @@
     ## Note that index.search() (currently?) only returns the first
     ## match for the given sequence of indices, and returns the empty
     ## string in case of no match.
-    paths <- sapply(.find.package(package, lib.loc, verbose = verbose),
+
+    ## (which is a problem under Ra when searching within core packages)
+    LibPaths <- .libPaths()
+    RaLib <- dirname(system.file(package = "base"))
+    GoodPaths <- LibPaths[LibPaths != RaLib]
+    
+    paths <- sapply(.find.package(package, verbose = verbose,
+                    lib.loc = if(is.null(lib.loc)) GoodPaths else lib.loc),
                     function(p) index.search(topic, p, "AnIndex", type))
     paths <- paths[paths != ""]
 
@@ -72,7 +79,7 @@
        && is.logical(try.all.packages) && !is.na(try.all.packages)
        && try.all.packages && missing(package) && missing(lib.loc)) {
         ## Try all the remaining packages.
-        lib.loc <- .libPaths()
+        lib.loc <- GoodPaths
         packages <- .packages(all.available = TRUE, lib.loc = lib.loc)
         packages <- packages[is.na(match(packages, .packages()))]
         for(lib in lib.loc) {

Reply via email to