[Rd] .S3methods: issue in content of info data.frame
Hi, I was trying to get a list of S3 method for a given generic, along with the package in which they are defined, and I came across what looks like an issue in the data.frame returned in attribute 'info'. The column 'from' mostly gets the value "registered S3method for ..." except for visible methods. Is this the expected behavior? See code and output below. Thank you. Bests, Renaud $ Rscript -e "library(xtable); attr(.S3methods('plot'), 'info'); sessionInfo()" visible from generic isS4 plot.acf FALSE registered S3method for plotplot FALSE plot.data.frame FALSE registered S3method for plotplot FALSE plot.decomposed.ts FALSE registered S3method for plotplot FALSE plot.default TRUE graphicsplot FALSE plot.dendrogram FALSE registered S3method for plotplot FALSE plot.density FALSE registered S3method for plotplot FALSE plot.ecdf TRUEstatsplot FALSE plot.factor FALSE registered S3method for plotplot FALSE plot.formula FALSE registered S3method for plotplot FALSE plot.function TRUE graphicsplot FALSE plot.hclust FALSE registered S3method for plotplot FALSE plot.histogram FALSE registered S3method for plotplot FALSE plot.HoltWinters FALSE registered S3method for plotplot FALSE plot.isoreg FALSE registered S3method for plotplot FALSE plot.lm FALSE registered S3method for plotplot FALSE plot.medpolish FALSE registered S3method for plotplot FALSE plot.mlm FALSE registered S3method for plotplot FALSE plot.ppr FALSE registered S3method for plotplot FALSE plot.prcomp FALSE registered S3method for plotplot FALSE plot.princompFALSE registered S3method for plotplot FALSE plot.profile.nls FALSE registered S3method for plotplot FALSE plot.raster FALSE registered S3method for plotplot FALSE plot.specFALSE registered S3method for plotplot FALSE plot.stepfun TRUEstatsplot FALSE plot.stl FALSE registered S3method for plotplot FALSE plot.table FALSE registered S3method for plotplot FALSE plot.ts TRUEstatsplot FALSE plot.tskernelFALSE registered S3method for plotplot FALSE plot.TukeyHSDFALSE registered S3method for plotplot FALSE R version 3.3.2 (2016-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.1 LTS locale: [1] LC_CTYPE=en_ZA.UTF-8 LC_NUMERIC=C LC_TIME=en_ZA.UTF-8LC_COLLATE=en_ZA.UTF-8 LC_MONETARY=en_ZA.UTF-8 [6] LC_MESSAGES=en_ZA.UTF-8LC_PAPER=en_ZA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base other attached packages: [1] xtable_1.8-2 loaded via a namespace (and not attached): [1] tools_3.3.2 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Ubuntu console weird behaviour
Hi, I have been experiencing a weird behavior when running R in Ubuntu terminal. I don't know exactly what triggers the issue and could not find a 100% reproducible way of getting it. The problem is that sometimes (often after an error is thrown, or after copy/paste of plain text from an editor), the console acts as if its width was limited, breaking lines and makes very difficult to navigate into command history or edit previous commands. Essentially, the console is messed up and only comes back to normal when restarting R in a fresh session. I understand it is a bit of a poor error report, but I was hoping that people might have encountered the same issue (and would recognize it as described here). I looked at bash checkwinsize as suggested here and it is on: http://unix.stackexchange.com/questions/61584/how-to-solve-the-issue-that-a-terminal-screen-is-messed-up-usually-after-a-res Thank you. Bests, Renaud My settings are: R version 3.2.3 (2015-12-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 15.10 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_ZA.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_ZA.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_ZA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Renaud Gaujoux, PhD Systems Immunology - Technion, Haifa, Israel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Method from package dependency is not updated due to lazy load?
hors@R: person("First", "Last", email = "first.l...@example.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: methods License: What license is it under? LazyData: true Imports: pkgA> cat('import(pkgA)', file = 'test/pkgB/NAMESPACE', append = TRUE)> cat("+ callA <- function() genericA()+ setGeneric('genericA', package = 'pkgA')+ setMethod('genericA', 'character', function(x) genericA())+ ", file = 'test/pkgB/R/function.R')> > # install packages> install.packages('test/v1/pkgA', lib = 'test/lib', repos = NULL, quiet = TRUE)> install.packages('test/pkgB', lib = 'test/lib', repos = NULL, quiet = TRUE)> # this returns A-v1> system("Rscript -e \"library(pkgA, lib = 'test/lib'); genericA()\"")Loading required package: methods [1] "A-v1"> system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"")Loading required package: methods [1] "A-v1" [1] "A-v1"> > # install pkgA version 2> install.packages('test/v2/pkgA', lib = 'test/lib', repos = NULL, quiet = TRUE)> # this returns A-v2> system("Rscript -e \"library(pkgA, lib = 'test/lib'); genericA()\"")Loading required package: methods [1] "A-v2"> # this still returns A-v1> system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"")Loading required package: methods [1] "A-v1" [1] "A-v1"> > # re-install pkgB> install.packages('test/pkgB', lib = 'test/lib', repos = NULL, quiet = TRUE)> # this now returns A-v2> system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"")Loading required package: methods [1] "A-v2" [1] "A-v2" -- Renaud Gaujoux, PhD Systems Immunology - Technion, Haifa, Israel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] List S3 methods and defining packages
Thank you for your reply Martin. Your code made me realize that S3 methods are added to the .__S3MethodsTable__. of the package that defines the generic, not to the ones defining the method itself. How does things work in the case of a method from one package B masking the one from another package A? I don't get any warning message and there seems to be only one entry in the relevant .__S3MethodsTable__. Aren't these tables updated when the masking package B is detached? On 7 July 2015 at 21:01, Martin Morgan mtmor...@fredhutch.org wrote: On 07/07/2015 02:05 AM, Renaud Gaujoux wrote: Hi, from the man page ?methods, I expected to be able to build pairs (class,package) for a given S3 method, e.g., print, using attr(methods(print), 'info'). However all the methods, except the ones defined in base or S4 methods, get the 'from' value registered S3method for print, instead of the actual package name (see below for the first rows). Is this normal behaviour? If so, is there a way to get what I want: a character vector mapping class to package (ideally in loading order, but this I can re-order from search()). It's the way it has always been, so normal in that sense. There could be two meanings of 'from' -- the namespace in which the generic to which the method belongs is defined, and the namespace in which the method is defined. I think the former is what you're interested in, but the latter likely what methods() might be modified return. For your use case, maybe something like .S3methodsInNamespace - function(envir, pattern) { mtable - get(.__S3MethodsTable__., envir = asNamespace(envir)) methods - ls(mtable, pattern = pattern) env - vapply(methods, function(x) { environmentName(environment(get(x, mtable))) }, character(1)) setNames(names(env), unname(env)) } followed by nmspc = loadedNamespaces() lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, ^plot.) which reveals the different meanings of 'from', e.g., lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, ^plot.)[graphics] $graphics stats graphicsstats plot.acfplot.data.frame plot.decomposed.ts graphicsstatsstats plot.defaultplot.dendrogram plot.density stats graphics graphics plot.ecdfplot.factor plot.formula graphicsstats graphics plot.functionplot.hclust plot.histogram statsstatsstats plot.HoltWintersplot.isoregplot.lm statsstatsstats plot.medpolish plot.mlm plot.ppr statsstatsstats plot.prcomp plot.princomp plot.profile.nls graphicsstatsstats plot.raster plot.spec plot.stepfun stats graphicsstats plot.stl plot.tableplot.ts statsstats plot.tskernel plot.TukeyHSD Also this is for loaded, rather than attached, namespaces. Martin Morgan Thank you. Bests, Renaud visible from generic isS4 print.abbrev FALSE registered S3method for print print FALSE print.acf FALSE registered S3method for print print FALSE print.AES FALSE registered S3method for print print FALSE print.agnesFALSE registered S3method for print print FALSE print.anovaFALSE registered S3method for print print FALSE print.AnovaFALSE registered S3method for print print FALSE print.anova.loglm FALSE registered S3method for print print FALSE print,ANY-methodTRUE base print TRUE print.aov FALSE registered S3method for print print FALSE __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] List S3 methods and defining packages
Thanks Kevin, this indeed clarifies a bit the S3 method registration universe. On 8 July 2015 at 15:48, Kevin Wright kw.s...@gmail.com wrote: Not sure if this answers your question, but you can't unregister a method. See http://tolstoy.newcastle.edu.au/R/help/06/07/30791.html Kevin Wright On Wed, Jul 8, 2015 at 5:09 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Thank you for your reply Martin. Your code made me realize that S3 methods are added to the .__S3MethodsTable__. of the package that defines the generic, not to the ones defining the method itself. How does things work in the case of a method from one package B masking the one from another package A? I don't get any warning message and there seems to be only one entry in the relevant .__S3MethodsTable__. Aren't these tables updated when the masking package B is detached? On 7 July 2015 at 21:01, Martin Morgan mtmor...@fredhutch.org wrote: On 07/07/2015 02:05 AM, Renaud Gaujoux wrote: Hi, from the man page ?methods, I expected to be able to build pairs (class,package) for a given S3 method, e.g., print, using attr(methods(print), 'info'). However all the methods, except the ones defined in base or S4 methods, get the 'from' value registered S3method for print, instead of the actual package name (see below for the first rows). Is this normal behaviour? If so, is there a way to get what I want: a character vector mapping class to package (ideally in loading order, but this I can re-order from search()). It's the way it has always been, so normal in that sense. There could be two meanings of 'from' -- the namespace in which the generic to which the method belongs is defined, and the namespace in which the method is defined. I think the former is what you're interested in, but the latter likely what methods() might be modified return. For your use case, maybe something like .S3methodsInNamespace - function(envir, pattern) { mtable - get(.__S3MethodsTable__., envir = asNamespace(envir)) methods - ls(mtable, pattern = pattern) env - vapply(methods, function(x) { environmentName(environment(get(x, mtable))) }, character(1)) setNames(names(env), unname(env)) } followed by nmspc = loadedNamespaces() lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, ^plot.) which reveals the different meanings of 'from', e.g., lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, ^plot.)[graphics] $graphics stats graphicsstats plot.acfplot.data.frame plot.decomposed.ts graphicsstatsstats plot.defaultplot.dendrogram plot.density stats graphics graphics plot.ecdfplot.factor plot.formula graphicsstats graphics plot.functionplot.hclust plot.histogram statsstatsstats plot.HoltWintersplot.isoregplot.lm statsstatsstats plot.medpolish plot.mlm plot.ppr statsstatsstats plot.prcomp plot.princomp plot.profile.nls graphicsstatsstats plot.raster plot.spec plot.stepfun stats graphicsstats plot.stl plot.tableplot.ts statsstats plot.tskernel plot.TukeyHSD Also this is for loaded, rather than attached, namespaces. Martin Morgan Thank you. Bests, Renaud visible from generic isS4 print.abbrev FALSE registered S3method for print print FALSE print.acf FALSE registered S3method for print print FALSE print.AES FALSE registered S3method for print print FALSE print.agnesFALSE registered S3method for print print FALSE print.anovaFALSE registered S3method for print print FALSE print.AnovaFALSE registered S3method for print print FALSE print.anova.loglm FALSE registered S3method for print print FALSE print,ANY-methodTRUE base print TRUE print.aov FALSE registered S3method for print print FALSE __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N
[Rd] List S3 methods and defining packages
Hi, from the man page ?methods, I expected to be able to build pairs (class,package) for a given S3 method, e.g., print, using attr(methods(print), 'info'). However all the methods, except the ones defined in base or S4 methods, get the 'from' value registered S3method for print, instead of the actual package name (see below for the first rows). Is this normal behaviour? If so, is there a way to get what I want: a character vector mapping class to package (ideally in loading order, but this I can re-order from search()). Thank you. Bests, Renaud visible from generic isS4 print.abbrev FALSE registered S3method for print print FALSE print.acf FALSE registered S3method for print print FALSE print.AES FALSE registered S3method for print print FALSE print.agnesFALSE registered S3method for print print FALSE print.anovaFALSE registered S3method for print print FALSE print.AnovaFALSE registered S3method for print print FALSE print.anova.loglm FALSE registered S3method for print print FALSE print,ANY-methodTRUE base print TRUE print.aov FALSE registered S3method for print print FALSE __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] install.packages deletes PACKAGES file in local repo
Hi, running install.packages() to install a package from a local repository (i.e., starts with file:///) appears to delete the PACKAGES file that is in the src/contrib/ directory. This happens on a cluster running Scientific Linux release 6.4 (Carbon), but not on my Ubuntu local machine. Subsequent calls to install.packages() complain about src/contrib/PACKAGES not existing, although there still is a src/contrib/PACKAGES.gz file. Is this a know issue? Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] install.packages deletes PACKAGES file in local repo
Hi, I was only doing install.packages('pkgname'), with the local repo being defined in the default repos option. After retrying it just now, this issue mysteriously suddenly disappeared, and things work as expected whether on the front node or in a job on a node. Really no idea of what happened. Closing the thread. Thanks. On 6 December 2014 at 02:23, Gabriel Becker gmbec...@ucdavis.edu wrote: Can you post exact code, i have not seen this behavior, and I work with local repositories quite extensively on my current project. ~G On Fri, Dec 5, 2014 at 7:45 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, running install.packages() to install a package from a local repository (i.e., starts with file:///) appears to delete the PACKAGES file that is in the src/contrib/ directory. This happens on a cluster running Scientific Linux release 6.4 (Carbon), but not on my Ubuntu local machine. Subsequent calls to install.packages() complain about src/contrib/PACKAGES not existing, although there still is a src/contrib/PACKAGES.gz file. Is this a know issue? Thank you. Bests, Renaud [[alternative HTML version deleted]] __ 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 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Hi Martyn, It isn't hard to set up Rtools on Windows and you only need to do it once. Then you build a binary package on your development system to distribute to your users. Yes, but since I am working on Linux, it is slightly more steps involved in order to generate a windows binary (even using a virtual machine), compared to build and push source packages to my repository, for which I have shell scripts and make files that do that in seconds and in batch mode. When working in a fast bug fix-test cycle with windows users testing things out often times a day, these extra steps take much time overall. Without even considering any technical details there is a purely strategic issue here. If a system has been set up that is robust and widely tested, like the R packaging system, you are much better off working with it than trying to subvert it. Agreed completely. I really like R cross-platform packaging and checking system, and was just wondering if this conditional compilation option was possible using the flexibility of this very system. Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Thank you for the replies and hints. A 'pre-built windows binary' of what? Sorry this was not clear, src/ contains source code for a binary executable, which produces no .lib or .dll. It is all fine in a R development environment: * On Linux, the executable is compiled and copied to R_PACKAGE_DIR/binR_ARCH using a custom install.libs.R script. * Same thing on Windows, if Rtools is installed, install.packages compiles and installs both 32 and 64 bits .exe. You can easily ship a DLL or .exe for use on Windows: just make use of configure.win and/or Makefile.win. If you have a Makefile.win it will override the normal procedures for directory src. I have tried using Makevars.win, but this requires make to be installed (as by Rtools). So I guess using Makefile.win would also not work, on a classic non-development geared Windows host. Would using configure.win work without Rtools? OTOH, shipping something in exec will be installed everwhere. True, although it seems that sub-directories of exec/ are actually not installed though. Is this intentional? Watch out for sub-architectures: 'Windows' is in fact two platforms. We have over the years seen a lot of problem with people shipping 64-bit Windows binaries: 32-bit Windows does not recognize those. Indeed, and I think I properly take care of this in install.libs.R. @Grabriel: the package is provided as a source package. This one is installable locally from file, although in may case users actually get it through a personal CRAN-like repository, using argument type='both'. Thank you. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Maybe. Read the documentation and sources for yourself (see below). Not working, at least in my hands, as it requires `sh`. Yes, *and documented* True. I overlooked the beginning of the NB point. (including that it should not be used for Windows executables). Yes, that's why I use the suggested procedure that uses src/install.libs.R to copy compiled .exe files into binR_ARCH/. So, eventually, I guess the answer to the original question is: no, one cannot make install.packages skip compilation of a source package, only if on Windows, without having Rtools installed -- and in PATH. Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Hi, is it possible to make install.packages install a source package by compiling it on Unix, but skip compilation and use a pre-built windows binary (shipped in exec/) if installing on Windows? The package should be installable on Windows machines that do not have Rtools installed. This is to make the update process easier for users, because the C++ code does not change often, meaning that I can just send source packages built on Linux, with a binary executable built once in a while on win-builder. Note that this is for a package that is not meant for CRAN, so no policy issue here. Thank you. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] traceback does not show source line number of long calls when truncating output
Hi, in R-3.1.0 (Linux), traceback() does not show the source file line number for the truncated calls, when limiting the number of lines output for each call with argument max.lines. See sample code, output and session info below (in particular, output for call number 5). I guess this is not intended. Thank you. Bests, Renaud ## File: traceback.R a - function(...){ stop('this is an error') } # code to generate the long call # set.seed(123) # v - unique(replicate(10, { paste0(sample(letters[1:26]), collapse = ) })) # sprintf(a(%s), paste0(v, '=', 1, collapse = , )) a(htjuwakqxzpgrsbncvyofdmeli=1, ozgdvsnpaimweybtkulrhcfjxq=1, udnecprhlbgwtfjisyzoxaqmvk=1, jcfpzqyirwotbsehdngauxlkvm=1, mwvojdsfbqlchznegyirpkautx=1, qwzxlnyorhegackmvubfsjtipd=1, ofkylhmugjvdwzscirnexptbqa=1, sgolfwzrevpjnythbqxmdckuai=1, ezlfyoangrspdmihtuxkvwcbqj=1, gjetdqkmvwxufslhcbpirnazoy=1) ## In R source('traceback.R', keep.source = TRUE) traceback() traceback(max.lines = 2) sessionInfo() ## Output source('traceback.R', keep.source = TRUE) Error in a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, : this is an error traceback() 6: stop(this is an error) at traceback.R#1 5: a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, udnecprhlbgwtfjisyzoxaqmvk = 1, jcfpzqyirwotbsehdngauxlkvm = 1, mwvojdsfbqlchznegyirpkautx = 1, qwzxlnyorhegackmvubfsjtipd = 1, ofkylhmugjvdwzscirnexptbqa = 1, sgolfwzrevpjnythbqxmdckuai = 1, ezlfyoangrspdmihtuxkvwcbqj = 1, gjetdqkmvwxufslhcbpirnazoy = 1) at traceback.R#8 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source(traceback.R, keep.source = TRUE) traceback(max.lines = 2) 6: stop(this is an error) at traceback.R#1 5: a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, udnecprhlbgwtfjisyzoxaqmvk = 1, jcfpzqyirwotbsehdngauxlkvm = 1, ... 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source(traceback.R, keep.source = TRUE) sessionInfo() R version 3.1.0 (2014-04-10) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Proxy settings not honoured anymore
Hi, it seems that my proxy settings are not picked up by the R console any longer, although the environment variable http_proxy is set and exported. Is anybody experiencing this issue as well? Thank you. Bests, Renaud # System info (from R --vanilla) sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Proxy settings not honoured anymore
All right, just ignore this silly post, things magically came back into place... :| On 27 March 2014 17:28, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, it seems that my proxy settings are not picked up by the R console any longer, although the environment variable http_proxy is set and exported. Is anybody experiencing this issue as well? Thank you. Bests, Renaud # System info (from R --vanilla) sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] contrib.url in non-interactive mode
Hi, is it intended that one cannot install packages in non-interactive mode, without explicitly setting a CRAN mirror (see below)? Couldn't a default mirror be used in that case? Thank you. Bests, Renaud $ Rscript --vanilla -e install.packages('whatever') Installing package into '/home/renaud/R/x86_64-pc-linux-gnu-library/3.0' (as 'lib' is unspecified) Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages - grep - contrib.url Execution halted [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] S4 method for '[' with extra arguments: distinguishing between x[i] and x[i, ]
Hi, I want to implement a '[' for an S4 class, that behaves differently when called with a single index argument or multiple indexes (possibly missing), like what happens when subsetting matrices x[i] vs. x[i, ]. I manage to do it using nargs() and checking if drop is missing (see code below), but when I want to add an extra argument to the method (before drop), then the parent call somehow changes and always includes all indexes in the call (even missing ones) and nargs() always returns the same value. I thought there might be a generic for a single index (with no j in the definition) but could not find its definition, and can't see how setMethod will know for which '[' to define the method. Defining a method for signature(x = 'A', j = 'missing') has the same issue. Is there actually a way to do this? Thank you. Bests, Renaud # Code # Class A setClass('A', contains = 'character') # No extra argument is fine setMethod('[', 'A', function(x, i, j, ..., drop = TRUE){ ca - match.call() mdrop - missing(drop) Nargs - nargs() - !mdrop print(ca) print(nargs()) print(mdrop) print(Nargs) if( !missing(i) Nargs 3 ) TRUE else FALSE }) testA - function(){ a - new('A') tests - c('a[1]', 'a[1,]', 'a[,1]') sapply(tests, function(s){ message('\n#', s); message('single arg: ', eval(parse(text = s))) s - sub(']', ', drop = FALSE]', s, fixed = TRUE) message('\n#', s); message('single arg: ', eval(parse(text = s))) }) invisible() } testA() # with extra argument = cannot distinguish the calls setMethod('[', 'A', function(x, i, j, ..., extra = FALSE, drop = TRUE){ ca - match.call() mdrop - missing(drop) Nargs - nargs() - !mdrop print(ca) print(nargs()) print(mdrop) print(Nargs) if( !missing(i) Nargs 3 ) TRUE else FALSE }) testA() # System info sessionInfo() R.version # RESULTS # Class A setClass('A', contains = 'character') # No extra argument is fine setMethod('[', 'A', function(x, i, j, ..., drop = TRUE){ + ca - match.call() + mdrop - missing(drop) + Nargs - nargs() - !mdrop + print(ca) + print(nargs()) + print(mdrop) + print(Nargs) + if( !missing(i) Nargs 3 ) TRUE + else FALSE + }) [1] [ testA - function(){ + a - new('A') + tests - c('a[1]', 'a[1,]', 'a[,1]') + sapply(tests, function(s){ + message('\n#', s); message('single arg: ', eval(parse(text = s))) + s - sub(']', ', drop = FALSE]', s, fixed = TRUE) + message('\n#', s); message('single arg: ', eval(parse(text = s))) + }) + invisible() + } testA() #a[1] a[i = 1] [1] 2 [1] TRUE [1] 2 single arg: TRUE #a[1, drop = FALSE] a[i = 1, drop = FALSE] [1] 3 [1] FALSE [1] 2 single arg: TRUE #a[1,] a[i = 1] [1] 3 [1] TRUE [1] 3 single arg: FALSE #a[1,, drop = FALSE] a[i = 1, drop = FALSE] [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1] a[j = 1] [1] 3 [1] TRUE [1] 3 single arg: FALSE #a[,1, drop = FALSE] a[j = 1, drop = FALSE] [1] 4 [1] FALSE [1] 3 single arg: FALSE # with extra argument = cannot distinguish the calls setMethod('[', 'A', function(x, i, j, ..., extra = FALSE, drop = TRUE){ + ca - match.call() + mdrop - missing(drop) + Nargs - nargs() - !mdrop + print(ca) + print(nargs()) + print(mdrop) + print(Nargs) + if( !missing(i) Nargs 3 ) TRUE + else FALSE + }) [1] [ testA() #a[1] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1,] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1,, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE # System info sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base R.version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status
Re: [Rd] cat with backspace and newline characters
Anyway, thanks for all the experiments, and (to Renaud) support.rstudio.org is the place to report such problems. Funny how the post diverged to an RStudio-related issue. Anyway, I posted a link to this post at support.rstudio.org: http://support.rstudio.org/help/discussions/problems/9242-cat-with-backspace-and-newline-characters/ From the user point of view, the following behaviour still feels like a strange behaviour of the R prompt: cat(abc\b\b\b) c (with the cursor now position on the 'c') I don't know if there is a general official behaviour of prompt characters, but I think one expects the prompt to always follow whatever is printed by the previous R command, without corruption of the input line to be. Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] How to do package cleanup: hooks .onUnload, R_unload_mylib, .onDetach are not called on quit
Hi, it seems that the package hooks .onLoad and its C++ pendant R_unload_mylib are actually not called when R quits, but only when explicitly calling detach('package:mylib', unload = TRUE). Maybe this is platform specific, I'm on Ubuntu 13.10 - R 3.0.2 (see below). * is there a mechanism that a package can use to effectively do some cleanup on standard exit, such as calling cleaning up routines of a loaded third-party library? I tried .onDetach but it did not work either. * by curiosity, in what kind of practical situation would a user want to call detach(..., unload = TRUE)? * is there a reason why the hooks are not called on quit? Thank you. Bests, Renaud ### Sys.info() sysname release version Linux 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 nodename machinelogin X x86_64 renaud user effective_user renaud renaud sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to do package cleanup: hooks .onUnload, R_unload_mylib, .onDetach are not called on quit
Many thanks for all responses and clarification! It worked great by defining a dummy environment in the package namespace and calling reg.finalizer to attach the cleanup function to it. Bests, Renaud On 6 November 2013 13:54, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 06/11/2013 11:36, Duncan Murdoch wrote: On 13-11-06 5:26 AM, Renaud Gaujoux wrote: Hi, it seems that the package hooks .onLoad and its C++ pendant R_unload_mylib are actually not called when R quits, but only when explicitly calling detach('package:mylib', unload = TRUE). Maybe this is platform specific, I'm on Ubuntu 13.10 - R 3.0.2 (see below). No, this is by design. See ?setHook. * is there a mechanism that a package can use to effectively do some cleanup on standard exit, such as calling cleaning up routines of a loaded third-party library? I tried .onDetach but it did not work either. Yes, you can set a finalizer. See ?reg.finalizer. RODBC is one example. * by curiosity, in what kind of practical situation would a user want to call detach(..., unload = TRUE)? An example is when you want a different version of a package. (That might now work and probably will not if the package does not unload its DLL.) * is there a reason why the hooks are not called on quit? They are slow to run, and are usually not needed. Finalizers handle the rare cases where you really do need something to happen. Or to put it another way, the OS will do most of the unloading when it terminates the process, more efficiently than the process itself can. That includes 'unloading' DLLs and freeing memory. Duncan Murdoch Thank you. Bests, Renaud ### Sys.info() sysname release version Linux 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 nodename machinelogin X x86_64 renaud user effective_user renaud renaud sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
I agree that the handling of \b is not that strange, once one agrees on what \b actually means, i.e. go back one character and not delete previous character. The fact that R GUI on Mac and Windows interprets/renders it differently shows that normality and strangeness is quite relative though. To make my previous response clearer, I was just wondering if the printing of R prompt character after the evaluation of an expression could detect trailing \b from cat in stdout/stderr and shift its position so that it is displayed after the last printed character. For example cat(abc\b\b\b) would give abc and not a c But this is: 0) Again platform, front-end dependent; 1) maybe not be possible (e.g., can we actually move forward without printing a character that would erase the previous output?) 2) maybe not even desirable; 3) certainly not worth the effort anyway! I guess we can happily close this thread :D Many thanks. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
Maybe it's a Linux problem: cat(abc\b) ab cat(abc\b\n) abc sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Sys.info() sysname Linux release 3.11.0-12-generic version #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 nodename X machine x86_64 login X user X effective_user X On 1 November 2013 19:54, Dennis Murphy djmu...@gmail.com wrote: I can't reproduce the error, either: cat(abc\b) ab cat(abc\b\n) ab sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 package info snipped for brevity Dennis [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
Thanks for the clarification. This appears to be a terminal behaviour issue. It is user lack-of-understanding: there is no error here. I believe lack of understanding is probably amongst the top reasons why users post to the list and get happily enlightened. I don't think I said there was an error though, but only asked if this was normal behaviour, and apparently many standard Linux terminals get it wrong. This looks a bit sad for a very terminal-driven OS. Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] cat with backspace and newline characters
Hi, when mixing newline and backspace characters I get the following output (see below). In the second call, the backspace character is simply not applied. Is this normal behaviour? Thank you. cat(abc\b) ab cat(abc\b\n) abc [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
I don't know what the normal behaviour is. I was expecting the remaining of the line to be wiped out, but you must be right: the character 'c' is already printed, the cursor moves back one position and go to the next line, leaving the 'c' in place. But what about this one: cat(abc\b\b\b) c Here, I end up with the cursor being on the 'c', i.e. if I type something it erase the 'c'. It is strange that the 'c' appears _after_ the console prompt, isn't it? Renaud On 1 November 2013 13:41, Sean O'Riordain sean...@acm.org wrote: Hi Renaud, Are you sure it's not applied? is \b a backspace i.e. just move the cursor back one space, or is it a delete the character to the left of the cursor? Kind regards, Sean On 1 November 2013 11:06, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, when mixing newline and backspace characters I get the following output (see below). In the second call, the backspace character is simply not applied. Is this normal behaviour? Thank you. cat(abc\b) ab cat(abc\b\n) abc [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Windows] Behaviour of shell on error
Hi, on my R-3.0.2 windows (32bits) no error is thrown occurs when calling a shell command with intern=TRUE, mustWork=TRUE. Is this a intended/known behaviour? From the source of base::shell it is clear that mustWork is only used when intern=FALSE. This is not that clear from the help page: Arguments mustWork a logical; if TRUE failure to run the command will give an R error, if FALSE a warning and if NA, no R message. Value If intern = TRUE, a character vector giving the output of the command, one line per character string, or an error message if the command could not be run. Thank you. Bests, Renaud ## Example ### # no error as expected shell('notacommand') shell('notacommand', intern=TRUE) # error as expected shell('notacommand', mustWork = TRUE) # I am expecting to get an error here as well, but none is thrown shell('notacommand', intern = TRUE, mustWork = TRUE) sessionInfo() ### Output ### # no error as expected shell('notacommand') 'notacommand' is not recognized as an internal or external command, operable program or batch file. Warning messages: 1: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 2: In shell(notacommand) : 'notacommand' execution failed with error code 1 shell('notacommand', intern=TRUE) [1] 'notacommand' is not recognized as an internal or external command, [2] operable program or batch file. attr(,status) [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 # error as expected shell('notacommand', mustWork = TRUE) 'notacommand' is not recognized as an internal or external command, operable program or batch file. Error in shell(notacommand, mustWork = TRUE) : 'notacommand' execution failed with error code 1 In addition: Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 # I am expecting to get an error here as well, but none is thrown shell('notacommand', intern = TRUE, mustWork = TRUE) [1] 'notacommand' is not recognized as an internal or external command, [2] operable program or batch file. attr(,status) [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 sessionInfo() R version 3.0.2 (2013-09-25) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Bioc-devel] Clarifying/simplifying on the SVN-Github mirroring
Hi Dan, can't wait to walk this bridge. Could you tease us a bit on how it would work? Will it use github's svn interface and leave developers transparently use a plain github repo (possibly following some simple naming conventions)? Many thanks. Bests, Renaud On 26 September 2013 19:25, Dan Tenenbaum dtene...@fhcrc.org wrote: Hi Renaud, We're working on a github-svn bridge for Bioconductor packages, but it's not ready yet. We will definitely announce it when it is ready. It will supersede the document you're looking at, though there is nothing to stop you from continuing to use that if you want to. Dan - Original Message - From: Renaud Gaujoux ren...@mancala.cbio.uct.ac.za To: bioc-devel@r-project.org Sent: Thursday, September 26, 2013 1:09:15 AM Subject: [Bioc-devel] Clarifying/simplifying on the SVN-Github mirroring Hi, if I understood correctly the instructions on https://github.com/Bioconductor/BiocGithubHelp/wiki/Managing-your-Bioc-code-on-hedgehog-and-github , it is recommend to work/branch out directly on the local git-svn branch, and merge into the github master branch to sync code on github. Couple of questions on this: * what about feature branches? Should these branch out from the svn-bound branch? In this case I believe they won't be pushed to github? Easy branching is one of the nice feature of git, which I heavily use (through git-flow) so it is important that the different branches (devel, release, features) are sent back to github in order to really benefit from its management tools (issues, network graph, etc..) * the workflow seems to be the opposite of what Cameron Bracken's post suggests http://cameron.bracken.bz/git-with-r-forge , where one work on the github-bound master branch and merge back onto the svn-bound branch once happy, right? I have experimented Cameron's workflow and faced many times lots of conflict issues that are a hassle to solve on each merge. Does the Bioconductor workflow have this issue? Overall, I wonder if it wouldn't be easier (from the developer point of view) if Bioconductor build farm allowed to point to an external SVN repository? Since github provides such an interface that transparently serves github repos to SVN calls, this would just wave out the need for duplicated branches and git-svn integration trick. Possible? Que tal? R-forge used to propose such option, which is apparently and sadly not working anymore. It really avoided lots of head ache. Thank you. Bests, Renaud [[alternative HTML version deleted]] ___ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel [[alternative HTML version deleted]] ___ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
Re: [Rd] R CMD check: unknown option ?--outdir==RCHECK?
Hi, I believe this is kind of a long standing bug though. In R-3.0.1, but this also happened in previous versions, the long version '--outdir' is not recognised: For `R CMD check --outdir=mydir pkg_0.1.tar.gz` we get: Warning: unknown option --outdir=mydir But with `R CMD check -o mydir pkg_0.1.tar.gz` we get: * using log directory /home/renaud/Documents/projects/mydir/pkg.Rcheck ... which works perfectly fine, and puts pkg.Rcheck in 'mydir'. Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check: unknown option ?--outdir==RCHECK?
Oh... I read too quickly your previous post, which actually gives me some hope on explaining why some R-forge checks might be broken. Great thanks! :) On 21 May 2013 15:54, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 21/05/2013 8:13 AM, Renaud Gaujoux wrote: Hi, I believe this is kind of a long standing bug though. In R-3.0.1, but this also happened in previous versions, the long version '--outdir' is not recognised: For `R CMD check --outdir=mydir pkg_0.1.tar.gz` we get: Warning: unknown option --outdir=mydir But with `R CMD check -o mydir pkg_0.1.tar.gz` we get: * using log directory /home/renaud/Documents/** projects/mydir/pkg.Rcheck ... which works perfectly fine, and puts pkg.Rcheck in 'mydir'. I don't know how long standing it was, but as I said, it is purely a documentation bug. The name of the option is --output, not --outdir. Duncan Murdoch [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Bioc-devel] Bioconductor Package Builder and _R_CHECK_FORCE_SUGGESTS_
Thanks very much Dan -- and Steve. I perfectly understand that setting _R_CHECK_FORCE_SUGGESTS_=false globally is not really an option, and that checks must be as strict as possible. I am fine with using the Enhances field, since it keeps the dependency. Will fix the package and re-submit. An idea for a future bioconductor check feature, it would be nice if authors could specify which of the Suggests packages are to be ignored, this would give the desired flexibility, while giving control on those check holes, as well as enabling possible programmatic tests on these skipped dependencies. Bests, Renaud On 17 May 2013 23:41, Dan Tenenbaum dtene...@fhcrc.org wrote: On Thu, May 16, 2013 at 10:53 PM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, I am trying to submit a package to Bioconductor with a Suggests dependency to RcppOctave, which is not available on Windows or Mac, and available on Linux only if octave is installed (RcppOctave is mine as well but getting working on other platforms than Linux is not yet on the agenda). All builds go fine but checks are not performed due to this missing dependency. This can be solved using _R_CHECK_FORCE_SUGGESTS_ = false, which is what is used on CRAN, at least for Windows and Mac. Is there a recommended way around this? I know I could hide the dependency using require('RcppOctave', character.only = TRUE), but I am wondering if there is a Bioconducotr-chekc-specific solution to still keep the dependency listed in the DESCRIPTION file. What we have done in situations like this is to (mis-)use the Enhances: field. R CMD check will not fail if a package in Enhances is not present. We do not want to set _R_CHECK_FORCE_SUGGESTS_=false globally, because on our build system, in 99% of cases, we want to make sure that all Suggested packages really are present. We could conceivably set _R_CHECK_FORCE_SUGGESTS_=false when specific packages are checked, but that functionality does not exist yet. BTW, it looks like RcppOctave is not building on Mac because Octave is not installed on the Mac build machine a CRAN (though there may be other problems): http://www.r-project.org/nosvn/R.check/r-release-macosx-x86_64/RcppOctave-00install.html If you do use the Enhances approach, you'll of course have to make sure that any code in your vignette or unit tests that use RcppOctave will need to be run only if require(RcppOctave). Thanks, Dan Thank you. Bests, Renaud [[alternative HTML version deleted]] ___ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel [[alternative HTML version deleted]] ___ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel
[Rd] Namespace/inheritance problem in S4 methods for a union class
Hi, I started this post on bioc-devel but this seems to be more general: https://stat.ethz.ch/pipermail/bioc-devel/2013-May/004311.html See reproducible example from Martin below. Thank you. Renaud -- Forwarded message -- From: Martin Morgan mtmor...@fhcrc.org Date: 7 May 2013 19:55 Subject: Re: [Bioc-devel] ExpressionSet and LumiBatch: inheritance problem in S4 methods for union class To: Renaud Gaujoux ren...@mancala.cbio.uct.ac.za Cc: bioc-de...@r-project.org, dupan.m...@gmail.com I can replicate this with a simpler example, where PkgA has setClass(A, representation(x=numeric)) with NAMESPACE import(methods) exportClasses(A) PkgB has setClass(B, contains=A) NAMESPACE import(methods) importClassesFrom(PkgA, A) exportClasses(B) and then library(PkgA); library(PkgB) setClassUnion(C, c(matrix, A)) setGeneric(do, function(x) standardGeneric(do)) setMethod(do, C, function(x) done) leading to do(new(A)) [1] done do(new(B)) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘do’ for signature ‘B’ suggesting name space issues rather than something about ExpressionSet. The sample packages and test script are attached; it would be appropriate to pursue this on the R-devel mailing list. Martin -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 setClassUnion.tar.gz Description: GNU Zip compressed data __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Namespace/inheritance problem in S4 methods for a union class
I obviously cannot predict the implications as much as John, but would the followings be solutions: - setClassUnion looks up for subclasses of its elements and add them up, and setClass('A', ...) would update the union classes of any superclass of 'A'. removeClass would need to do some cleanup, which it probably does already. - OR, extends(class1) could lookup at runtime for union classes that include a superclass of class1. Caching on class1 could be used, reset by any subsequent call to setClass(class1, ...) or removeClass(class1). I guess setClassUnion would also do the same to deal with union of unions. Renaud On 8 May 2013 19:02, John Chambers j...@r-project.org wrote: No need for generic functions and methods. Just looking at the hierarchy of the classes shows the problem. With Martin's simplified version: library(PkgA) extends(A) [1] A library(PkgB) extends(B) [1] B A setClassUnion(C, c(matrix, A)) extends(A) [1] A C extends(B) [1] B A So defining the union does not make all the subclasses of A members of the union. The next comments are guesses but plausible. Loading the namespace of PkgB may not update the known subclasses of classes from PkgA. This is one of R's touchier points in general: The state of things with respect to classes and methods changes dynamically as packages are loaded. Until PkgB is loaded, A has no known subclasses. If the guess is correct, then when the class union is formed, nothing tells us that A has a subclass B that should be added to the union. Fixing this properly may involve the load-time actions and not be quite trivial. John On 5/7/13 11:05 PM, Renaud Gaujoux wrote: Hi, I started this post on bioc-devel but this seems to be more general: https://stat.ethz.ch/**pipermail/bioc-devel/2013-May/**004311.htmlhttps://stat.ethz.ch/pipermail/bioc-devel/2013-May/004311.html See reproducible example from Martin below. Thank you. Renaud -- Forwarded message -- From: Martin Morgan mtmor...@fhcrc.org Date: 7 May 2013 19:55 Subject: Re: [Bioc-devel] ExpressionSet and LumiBatch: inheritance problem in S4 methods for union class To: Renaud Gaujoux ren...@mancala.cbio.uct.ac.za** Cc: bioc-de...@r-project.org, dupan.m...@gmail.com I can replicate this with a simpler example, where PkgA has setClass(A, representation(x=numeric)) with NAMESPACE import(methods) exportClasses(A) PkgB has setClass(B, contains=A) NAMESPACE import(methods) importClassesFrom(PkgA, A) exportClasses(B) and then library(PkgA); library(PkgB) setClassUnion(C, c(matrix, A)) setGeneric(do, function(x) standardGeneric(do)) setMethod(do, C, function(x) done) leading to do(new(A)) [1] done do(new(B)) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function do for signature B suggesting name space issues rather than something about ExpressionSet. The sample packages and test script are attached; it would be appropriate to pursue this on the R-devel mailing list. Martin __** R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-develhttps://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] lsfit: Error in formatting error message
Ah yes, nice, I had noticed the swapped words in other situations, it will definitely help me to tell users about sample size issues... :) Bests, Renaud On 29 April 2013 12:15, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 25.04.2013 13:29, Renaud Gaujoux wrote: Hi, in R-3.0 I get the following error when calling lsfit with more observations than variables, which seems to come from an error in the formatting of the error message (note that this was not happening in 2.15.3): nobs - 5; nvar - 6; lsfit(matrix(runif(nobs*nvar), ncol=nvar), runif(nobs), intercept=FALSE) Error in sprintf(ngettext(nry, %d response, %d responses), , , ngettext(ncx, : invalid format '%d'; use format %s for character objects traceback() 3: sprintf(ngettext(nry, %d response, %d responses), , , ngettext(ncx, but only %d variable, but only %d variables), nry, ncx) 2: stop(sprintf(ngettext(nry, %d response, %d responses), , , ngettext(ncx, but only %d variable, but only %d variables), nry, ncx), domain = NA) 1: lsfit(matrix(runif(nobs * nvar), ncol = nvar), runif(nobs), intercept = FALSE) Thanks, fixed in R-patched and R-devel (plus the wording which was inappropriate for more than 10 years, at least). Best, Uwe Ligges Thank you. Bests, Renaud [[alternative HTML version deleted]] __** R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-develhttps://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Empty package skeleton
... and my suggestion for an easy way to skip defined variables comes from the case of fresh non-vanilla sessions that willingly inherit user-defined variables from .Rprofile. 2013/4/14 Dirk Eddelbuettel e...@debian.org On 14 April 2013 at 14:10, Renaud Gaujoux wrote: | Hi, | | I know this has been reported/asked before ( | http://tolstoy.newcastle.edu.au/R/e15/devel/11/10/0831.html) but it would | still be just nice to have a fix for the not user-friendly fact that one | cannot create a completely empty package skeleton (see previous post for a | suggested patch). | | In the same vein, I would add to the original suggestion from Herve Pages | that it would be nice to have a quick way to create an empty package | skeleton, skipping all objects possibly defined in .GlobalEnv, e.g. | package.skeleton('pkg', NA), although I believe Herve's patch would | automatically allow/handle a call like package.skeleton('pkg', | character()). | | Conclusion, nothing urgent, which could be done in 1min spare time, but | could save 1min to many friendly future package developers :) I am also willing to help here as I do not like the fact that the generated Rd file itself is broken. A hint from R Core that clean patches would be taken would be welcomed... [ And I often call package.skeleton() from a fresh session, that is pretty close to creating an empty package. ] Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] loadNamespace tries to load an optional dependency from a required dependency
Hi, I get an error from loadNamespace in the following situation (on R-2.15.3, R-devel 2013-03-26 r62409, and fresh R-3.0.0): - package A has an optional (suggests) dependency to package C, which is tested at load time in .onLoad, via require(). - package B depends on package A, which is loaded when B is lazy-loaded at install time. - package B is installed with package C installed If one now removes package C and try loading package B via library(B), then one gets an error such as: Error in loadNamespace(name) : there is no package called C Error: package/namespace load failed for B I guess this is because the list of namespaces to load for B is taken from the frozen list defined after lazyload at install time. Is this an intentional requirement or shouldn't the list of dependency namespaces to load be taken from the NAMESPACE and/or DESCRIPTION file, which define the true dependencies? Package B should not have to be aware of how/when the optional dependencies of package A are loaded. I believe these are legally conditionally loaded in .onLoad or should they be loaded in .onAttach? One could imagine a situation where a package actually does require the extra functionality provided by package C, at lazy-load time, which means it must be loaded via .onLoad (right?). In this case, clearly, one would have package C as Depends, which then would not give rise to the issue I have here. Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] source, sys.source and error line numbers
Sounds good for me. Thanks. 2013/3/27 Duncan Murdoch murdoch.dun...@gmail.com On 13-03-26 6:45 PM, Hadley Wickham wrote: It turns out the reason for this is pretty simple: sys.source does: for (i in exprs) eval(i, envir) where source basically does n - length(exprs) for (i in seq_len(n)) eval(expr[i], envir) so the problem is presumably related to the way that for strips attributes. That's part of it, but there are also different defaults for keep.source. It needs to be TRUE or the error location won't be known. I'll fix the difference you noticed after 3.0.0 is released; I think it is not serious enough to slip in at this point. Duncan Murdoch Hadley On Tue, Mar 19, 2013 at 4:03 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za** wrote: Hi, is there a way to retrieve the line number of where en error occurred when sourcing a file in a tryCatch statement? Is it stored somewhere accessible? It is not found in the error object. Consider the following code/output and note the difference in the traceback between source (has line number) and sys.source (has no line number). Thank you, Renaud # code codefile - tempfile() write(# some comment # some good lines a - 1 # a bad line stop('an error') # another good line b - 2 , file=codefile) # with source() the line number is displayed source(codefile) traceback() tryCatch(source(codefile), error= function(e){ str(e) }) # with sys.source() the line number is _not_ displayed e - new.env() sys.source(codefile, e) traceback() sessionInfo() # # output # codefile - tempfile() write(# some comment + # some good lines + a - 1 + # a bad line + stop('an error') + # another good line + b - 2 + , file=codefile) # with source() the line number is displayed source(codefile) Error in eval(expr, envir, enclos) : an error traceback() 5: stop(an error) at file46641af8754#5 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source(codefile) tryCatch(source(codefile), error= function(e){ str(e) }) List of 2 $ message: chr an error $ call : language eval(expr, envir, enclos) - attr(*, class)= chr [1:3] simpleError error condition # with sys.source() the line number is _not_ displayed e - new.env() sys.source(codefile, e) Error in eval(expr, envir, enclos) : an error traceback() 4: stop(an error) 3: eval(expr, envir, enclos) 2: eval(i, envir) 1: sys.source(codefile, e) sessionInfo() R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __** R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-develhttps://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] removing union class
All good then. Thanks. Renaud 2013/3/19 Martin Maechler maech...@stat.math.ethz.ch RG == Renaud Gaujoux ren...@mancala.cbio.uct.ac.za on Sun, 17 Mar 2013 10:38:44 +0200 writes: RG Late report is better than never isn't it? :) Well,... you forgot to show the error (and the traceback) : RG Apologies, I usually include them (and sessionInfo ...). Note that this problem is somewhat dependent on the use of the infamous matrix class {not properly defined as a class in S3, as it may or may not have dimnames, and then tried to be made S4 compatible as well as possible in the methods package, see RG Ok. What I want to do is to define a class in my RG namespace that gather some matrix-like classes so that I RG can define a set of common functions for them. RG Initially I want matrix and ExpressionSet objects, and RG possibly add array objects later. Union classes seem to RG be exactly the way to go, but maybe there is an RG alternative? There's really *no* problem with class unions. They work fine and nicely... we also use them in the Matrix package (part of the R distro). The problem you've reported is only a propblem of removeClass(). Martin Of course, I could not have thought of a realistic situation where this was a problem, but then you exemplify one : Hadley, this is problematic for devtools, because load_all tries to cleanup S4 classes when an error occurs when loading a development package and crashes with no hint on the original error. RG I guess a quick fix for devtools, would be to wrap the RG cleanup procedure into a try or tryCatch (Hadley?). RG Thanks, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] source, sys.source and error line numbers
Hi, is there a way to retrieve the line number of where en error occurred when sourcing a file in a tryCatch statement? Is it stored somewhere accessible? It is not found in the error object. Consider the following code/output and note the difference in the traceback between source (has line number) and sys.source (has no line number). Thank you, Renaud # code codefile - tempfile() write(# some comment # some good lines a - 1 # a bad line stop('an error') # another good line b - 2 , file=codefile) # with source() the line number is displayed source(codefile) traceback() tryCatch(source(codefile), error= function(e){ str(e) }) # with sys.source() the line number is _not_ displayed e - new.env() sys.source(codefile, e) traceback() sessionInfo() # # output # codefile - tempfile() write(# some comment + # some good lines + a - 1 + # a bad line + stop('an error') + # another good line + b - 2 + , file=codefile) # with source() the line number is displayed source(codefile) Error in eval(expr, envir, enclos) : an error traceback() 5: stop(an error) at file46641af8754#5 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source(codefile) tryCatch(source(codefile), error= function(e){ str(e) }) List of 2 $ message: chr an error $ call : language eval(expr, envir, enclos) - attr(*, class)= chr [1:3] simpleError error condition # with sys.source() the line number is _not_ displayed e - new.env() sys.source(codefile, e) Error in eval(expr, envir, enclos) : an error traceback() 4: stop(an error) 3: eval(expr, envir, enclos) 2: eval(i, envir) 1: sys.source(codefile, e) sessionInfo() R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] removing union class
Late report is better than never isn't it? :) Well,... you forgot to show the error (and the traceback) : Apologies, I usually include them (and sessionInfo ...). Note that this problem is somewhat dependent on the use of the infamous matrix class {not properly defined as a class in S3, as it may or may not have dimnames, and then tried to be made S4 compatible as well as possible in the methods package, see Ok. What I want to do is to define a class in my namespace that gather some matrix-like classes so that I can define a set of common functions for them. Initially I want matrix and ExpressionSet objects, and possibly add array objects later. Union classes seem to be exactly the way to go, but maybe there is an alternative? Of course, I could not have thought of a realistic situation where this was a problem, but then you exemplify one : Hadley, this is problematic for devtools, because load_all tries to cleanup S4 classes when an error occurs when loading a development package and crashes with no hint on the original error. I guess a quick fix for devtools, would be to wrap the cleanup procedure into a try or tryCatch (Hadley?). Thanks, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] removing union class
Hi, I get the following error when trying to remove a union class: setClassUnion('a', c('matrix', 'numeric')) removeClass('a') sessionInfo() R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Is this normal? Am I doing something wrong? Hadley, this is problematic for devtools, because load_all tries to cleanup S4 classes when an error occurs when loading a development package and crashes with no hint on the original error. Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Call function only when running via R CMD check?
Hi Henrik (and list), I am interested in a similar feature, and would be happy to see the suggestions you got off-line :) Have you come up with a robust solution, which would work in a variety of situations (in examples, tests, \Sexpr calls, etc..)? Thank you. Bests, Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Extracting srcref for S4 methods
Responding to my own question here. It appears I had overlooked the results from my sample script, as they in fact do contain srcref data, but simply do not show them up in str(): f - textConnection( f - function(){} setGeneric('myfun', function(x, ...) standardGeneric('myfun')) setMethod('myfun', 'numeric', function(x, ...){ 'myfun,numeric' }) ) source(f, keep.source=TRUE) # there are srcref data for functions str(f) # no srcref data str(attr(myfun, 'srcref')) str(attr(selectMethod(myfun, 'numeric'), 'srcref')) So no worries. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Suggestion] Installation of CRAN packages that depend on Bioconductor packages
Hi, as far as I know, calling a plain: install.packages('packageA') with packageA having a dependency to packageB from Bioconductor will not complete without having a Bioc mirror setup in options('repos') or specifying it in argument 'repos'. CRAN/R-forge checks resolve such dependencies automatically. Would it be possible (and not problematic) to also resolve such standard dependencies at install time (in fact build time) and automatically append a Bioc mirror to repos within install.package (if none is already defined)? The dependency would be hence completely transparent, which would simplify the installation of such packages, as the user would not need to know that a repository other than CRAN is required. Resolution could make use of the function chooseBioCMirror to ask the user to select her preferred mirror, as it is done for the CRAN mirror. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Incompatible methods for overloaded operator
Hi, I may be mistaken here but a possible interpretation of: If a method is found for just one argument or the same method is found for both, it is used. could be that the same method here does not mean identical in term of object/content (as identical tests), but means that the two arguments resolve to the same method definition, i.e. a single common method exists for both arguments. This would happen is if a single method is defined for a common parent class. Try: `+.C` - function(x1, x2){ message(Running custom + function) } x - structure(1, class=c('A', 'C')) y - structure(1, class=c('B', 'C')) x + y Another work around would be to define only one method for class 'a' and do the dispatch to `plus.b` in there (might even be able to call it `+.b` if not exported). Might be a good suggestion to add a test in UseMethod to check is the methods are in fact identical. But there might be undesired side effects: two identical methods in different environment that behave differently depending on the state of the environment? By the way any way of seeing any code of primitive function or are these pure C functions, which need to be searched for in R source code? Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple sub-architecture: linking issue
Dirk, who thinks this should have been on r-sig-debian all along Moved to r-sig-debian as suggested: https://stat.ethz.ch/pipermail/r-sig-debian/2012-June/001885.html __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple sub-architecture: linking issue
On 11/06/2012 03:43, Simon Urbanek wrote: On Jun 10, 2012, at 9:24 PM, Dirk Eddelbuettel wrote: On 8 June 2012 at 12:27, Renaud Gaujoux wrote: | PS: Dirk do you want me to post this on the Rcpp list for record? Yes, that generally is where Rcpp questions / comments / hints should go. As for multi-arch builds, I am not sure we even thought about supporting this so if it breaks your use of Rcpp and related packages, you get to keep the pieces. That said, I'd be interested in supporting it eventually but I guess I want to first understand better how/if it is supported (on Linux) by R itself. R itself of course supports it and essentially all packages (including Rcpp ;)) have to because we require it on Windows and OS X since all binaries there are multi-lib. From what I understood fro R-Writing extensions, multi-arch support would generally be about following the following recommendation: If you want to run R code inMakevars, e.g. to find configuration information, please do ensure that you use the correct copy of|R|or|Rscript|: there might not be one in the path at all, or it might be the wrong version or architecture. The correct way to do this is/via/ $(R_HOME)/bin$(R_ARCH_BIN)/Rscriptfilename $(R_HOME)/bin$(R_ARCH_BIN)/Rscript -e 'R expression' where|$(R_ARCH_BIN)|is only needed currently on Windows. So unless different external libraries are required for the different types build (32 or 64 bits), there should be nothing special to do to ensure support of multi-arch. In particular, on Linux, $(R_HOME)/bin/Rscript -e 'R expression' should work in both single and multi-arch setup, correct? As far as R is concerned it works equally well on Linux - the problem there is more on the side of distributions, because it is more unusual to have multi-lib Linux (originally it was used on Linux only to get 3rd party [mostly proprietary] 32-bit binaries working on 64-bit systems and that is now less of an issue). As I said in the original post it works reasonably well on Debian (not for all libraries since only a subset is available, but all the basic ones) -- there were shakeups in Ubuntu which were messing with the multilib support, so I don't know the current status but I can check at work tomorrow (probably not for something as ancient as natty, though). I think you are right Simon: the issue likely comes from my Linux distrib, which I effectively should upgrade. This gives me one more reason to do it asap. If you have some -- even untested -- clues on how to get things working on Natty I am happy to test them though, as upgrades always have hidden issues and time black holes... Thank you. Bests, Renaud Cheers, Simon -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Multiple sub-architecture: problem installing RCurl
Hi, for checking purposes, I setup a multiple sub-architecture R installation following this post from Simon Urbanek: https://stat.ethz.ch/pipermail/r-devel/2011-August/061755.html It all went fine. The only change I made to Simon's procedure was to install with: make prefix=~/bin/R/2.15 install instead of sudo make install rhome=/usr/local/R/2.15. I am now trying to install RCurl in the 32 bits architechture but get the following error, which I believe comes from the fact the wrong libraries (64 bits) are used instead of the 32 bit ones. I am on Ubuntu 11.04 (Natty) and thought I needed to install the 32 bits libxml2, but could not find a way to do so. Anybody faced a similar problem? I believe I will get into the same kind of issue with other packages that require system packages. Thank you! . libcurl version: libcurl 7.21.3 configure: creating ./config.status config.status: creating src/Makevars ** libs *** arch - i386 gcc -std=gnu99 -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLINFO_EFFECTIVE_URL=1 -DHAVE_CURLINFO_RESPONSE_CODE=1 -DHAVE_CURLINFO_TOTAL_TIME=1 -DHAVE_CURLINFO_NAMELOOKUP_TIME=1 -DHAVE_CURLINFO_CONNECT_TIME=1 -DHAVE_CURLINFO_PRETRANSFER_TIME=1 -DHAVE_CURLINFO_SIZE_UPLOAD=1 -DHAVE_CURLINFO_SIZE_DOWNLOAD=1 -DHAVE_CURLINFO_SPEED_DOWNLOAD=1 -DHAVE_CURLINFO_SPEED_UPLOAD=1 -DHAVE_CURLINFO_HEADER_SIZE=1 -DHAVE_CURLINFO_REQUEST_SIZE=1 -DHAVE_CURLINFO_SSL_VERIFYRESULT=1 -DHAVE_CURLINFO_FILETIME=1 -DHAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD=1 -DHAVE_CURLINFO_CONTENT_LENGTH_UPLOAD=1 -DHAVE_CURLINFO_STARTTRANSFER_TIME=1 -DHAVE_CURLINFO_CONTENT_TYPE=1 -DHAVE_CURLINFO_REDIRECT_TIME=1 -DHAVE_CURLINFO_REDIRECT_COUNT=1 -DHAVE_CURLINFO_PRIVATE=1 -DHAVE_CURLINFO_HTTP_CONNECTCODE=1 -DHAVE_CURLINFO_HTTPAUTH_AVAIL=1 -DHAVE_CURLINFO_PROXYAUTH_AVAIL=1 -DHAVE_CURLINFO_OS_ERRNO=1 -DHAVE_CURLINFO_NUM_CONNECTS=1 -DHAVE_CURLINFO_SSL_ENGINES=1 -DHAVE_CURLINFO_COOKIELIST=1 -DHAVE_CURLINFO_LASTSOCKET=1 -DHAVE_CURLINFO_FTP_ENTRY_PATH=1 -DHAVE_CURLINFO_REDIRECT_URL=1 -DHAVE_CURLINFO_PRIMARY_IP=1 -DHAVE_CURLINFO_APPCONNECT_TIME=1 -DHAVE_CURLINFO_CERTINFO=1 -DHAVE_CURLINFO_CONDITION_UNMET=1 -DHAVE_CURLOPT_KEYPASSWD=1 -DHAVE_CURLOPT_DIRLISTONLY=1 -DHAVE_CURLOPT_APPEND=1 -DHAVE_CURLOPT_KRBLEVEL=1 -DHAVE_CURLOPT_USE_SSL=1 -DHAVE_CURLOPT_TIMEOUT_MS=1 -DHAVE_CURLOPT_CONNECTTIMEOUT_MS=1 -DHAVE_CURLOPT_HTTP_TRANSFER_DECODING=1 -DHAVE_CURLOPT_HTTP_CONTENT_DECODING=1 -DHAVE_CURLOPT_NEW_FILE_PERMS=1 -DHAVE_CURLOPT_NEW_DIRECTORY_PERMS=1 -DHAVE_CURLOPT_POSTREDIR=1 -DHAVE_CURLOPT_OPENSOCKETFUNCTION=1 -DHAVE_CURLOPT_OPENSOCKETDATA=1 -DHAVE_CURLOPT_COPYPOSTFIELDS=1 -DHAVE_CURLOPT_PROXY_TRANSFER_MODE=1 -DHAVE_CURLOPT_SEEKFUNCTION=1 -DHAVE_CURLOPT_SEEKDATA=1 -DHAVE_CURLOPT_CRLFILE=1 -DHAVE_CURLOPT_ISSUERCERT=1 -DHAVE_CURLOPT_ADDRESS_SCOPE=1 -DHAVE_CURLOPT_CERTINFO=1 -DHAVE_CURLOPT_USERNAME=1 -DHAVE_CURLOPT_PASSWORD=1 -DHAVE_CURLOPT_PROXYUSERNAME=1 -DHAVE_CURLOPT_PROXYPASSWORD=1 -DHAVE_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5=1 -DHAVE_CURLOPT_NOPROXY=1 -DHAVE_CURLOPT_TFTP_BLKSIZE=1 -DHAVE_CURLOPT_SOCKS5_GSSAPI_SERVICE=1 -DHAVE_CURLOPT_SOCKS5_GSSAPI_NEC=1 -DHAVE_CURLOPT_PROTOCOLS=1 -DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -DHAVE_CURLOPT_SSH_AUTH_TYPES=1 -DHAVE_CURLOPT_SSH_PUBLIC_KEYFILE=1 -DHAVE_CURLOPT_SSH_PRIVATE_KEYFILE=1 -DHAVE_CURLOPT_FTP_SSL_CCC=1 -DHAVE_CURLOPT_COOKIELIST=1 -DHAVE_CURLOPT_IGNORE_CONTENT_LENGTH=1 -DHAVE_CURLOPT_FTP_SKIP_PASV_IP=1 -DHAVE_CURLOPT_FTP_FILEMETHOD=1 -DHAVE_CURLOPT_LOCALPORT=1 -DHAVE_CURLOPT_LOCALPORTRANGE=1 -DHAVE_CURLOPT_CONNECT_ONLY=1 -DHAVE_CURLOPT_CONV_FROM_NETWORK_FUNCTION=1 -DHAVE_CURLOPT_CONV_TO_NETWORK_FUNCTION=1 -DHAVE_CURLOPT_CONV_FROM_UTF8_FUNCTION=1 -DHAVE_CURLOPT_MAX_SEND_SPEED_LARGE=1 -DHAVE_CURLOPT_MAX_RECV_SPEED_LARGE=1 -DHAVE_CURLOPT_FTP_ALTERNATIVE_TO_USER=1 -DHAVE_CURLOPT_SOCKOPTFUNCTION=1 -DHAVE_CURLOPT_SOCKOPTDATA=1 -DHAVE_CURLOPT_SSL_SESSIONID_CACHE=1 -I/usr/include/libxml2 -I/usr/local/include-fpic -g -O2 -c base64.c -o base64.o In file included from /usr/include/curl/curl.h:35:0, from Rcurl.h:4, from base64.c:1: /usr/include/curl/curlrules.h:142:3: error: size of array '__curl_rule_01__' is negative /usr/include/curl/curlrules.h:152:3: error: size of array '__curl_rule_02__' is negative make: *** [base64.o] Error 1 ERROR: compilation failed for package 'RCurl' * removing '/home/renaud/bin/R/2.15/lib64/R/library/RCurl' * restoring previous '/home/renaud/bin/R/2.15/lib64/R/library/RCurl' -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Multiple sub-architecture: linking issue
Hi again, following my previous post on RCurl, I cannot install Rcpp either: g++ -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -I../inst/include/ -I/usr/local/include-fpic -g -O2 -c r_cast.cpp -o r_cast.o g++ -m32 -shared -L/usr/local/lib64 -o Rcpp.so Date.o DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o Environment.o Evaluator.o Formula.o Function.o Language.o Module.o Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status There is definitely some conflict or missing libraries going on... Any help is appreciated. Thank you. PS: Dirk do you want me to post this on the Rcpp list for record? -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple sub-architecture: linking issue
Thank you for your reply Simon. I have the gcc-multilib and ia32-libs packages installed (I think their installation is part of the procedure you described in your previous post). Could not find the package ia32-dev you mention. It seems to be flagged as obsolete in Natty repositories: $ sudo apt-get install ia32-libs-dev lib32readline6-dev lib32ncurses5-dev lib32icu-dev gcc-multilib gfortran-multilib [sudo] password for renaud: Reading package lists... Done Building dependency tree Reading state information... Done Package ia32-libs-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: lib32bz2-dev ia32-libs lib32z1-dev I succeeded in compiling both architecture of R without a problem though. Would that have been possible if some of the files provided by this package were missing? I can try look around for this exact package. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 08/06/2012 16:22, Simon Urbanek wrote: Make sure you have installed multilib gcc and the ia32 dev packages - it seems you don't have them. I'm a Sent from my iPhone On Jun 8, 2012, at 6:27 AM, Renaud Gaujouxren...@mancala.cbio.uct.ac.za wrote: Hi again, following my previous post on RCurl, I cannot install Rcpp either: g++ -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -I../inst/include/ -I/usr/local/include-fpic -g -O2 -c r_cast.cpp -o r_cast.o g++ -m32 -shared -L/usr/local/lib64 -o Rcpp.so Date.o DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o Environment.o Evaluator.o Formula.o Function.o Language.o Module.o Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status There is definitely some conflict or missing libraries going on... Any help is appreciated. Thank you. PS: Dirk do you want me to post this on the Rcpp list for record? -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] url, readLines, source behind a proxy
On 23/04/2012 17:39, Prof Brian Ripley wrote: On 18/04/2012 16:04, Joshua Ulrich wrote: Hi Renaud, On Wed, Apr 18, 2012 at 12:22 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi Henrik, snip Could anybody behind a proxy check if the issue can be reproduced? My proxy is in fact provided by cntml, which acts as a local proxy that takes care of tricky authentication protocols with the actual university proxy, not natively supported by my system (Ubuntu). Anybody in this case? I can replicate this on a WinXP system, where I normally have to use the --internet2 flag to get internet access through a proxy. ?download.file has a section on Setting Proxies, which describes how to use environment variables to set proxy information. Setting http_proxy='http://my.proxy.com/' was enough for me to get R CMD check to run successfully with the --as-cran flag. I guess that the simplest way on Windows is to ensure that --internet2 is set. In R-patched there is a new environment variable R_WIN_INTERNET2 which lets you do that (set it in ~/.R/check.Renviron). [Setting proxies is so 20th century -- even moderately competent sysadmins worked out how to use transparent caching proxies ca 1995. Which is why the R developers give it a low priority.] I completely understand the low priority -- fast-illimited-internet based -- point of view. I wish I could live without such a fussy proxy, but I have not much choice. I like to understand why things work and do not work though. Is there any special feature my proxy should have to allow readLines/source to correctly read remote data? What makes its access different from wget? Thank you for your insights on this. Thanks. Renaud Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com R/Finance 2012: Applied Finance with R www.RinFinance.com On Tue, 17 Apr 2012, Henrik Bengtsson wrote: On Tue, Apr 17, 2012 at 1:01 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, when I run R CMD check with flag --as-cran, the process hangs at stage: * checking CRAN incoming feasibility ... Doesn't it time-out eventually? I'm not behind a proxy but when I've been running 'R CMD check' whenon very poor 3G connection, it had eventually timed out. /Henrik I am pretty sure it is a proxy issue. I looked at the check code in the tools package and it seems that the issue is in the local function `.repository_db()` (defined in `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` with argument open=rb, that hangs probably because it does not use the proxy settings. I had a similar issue with `source()`, which apparently uses internal network functions (not as download.file), but is supposed to work behind a proxy (correct?). Does anybody else have this problem? I was wondering if there is a way around, as I would like to be able to use --as-cran for my checks. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] url, readLines, source behind a proxy
Hi Henrik, I am sure it would time out indeed. I am fine with time out due to poor connection, but get a bit frustrated if my connection is fine and timeout occurs because proxy settings are not read. All the more if I have to run R CMD check multiple times and wait for the timeout. But the issue might also be coming from my proxy, which somehow does not like the way url() reads remote content. Could anybody behind a proxy check if the issue can be reproduced? My proxy is in fact provided by cntml, which acts as a local proxy that takes care of tricky authentication protocols with the actual university proxy, not natively supported by my system (Ubuntu). Anybody in this case? Thanks. Renaud On Tue, 17 Apr 2012, Henrik Bengtsson wrote: On Tue, Apr 17, 2012 at 1:01 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, when I run R CMD check with flag --as-cran, the process hangs at stage: * checking CRAN incoming feasibility ... Doesn't it time-out eventually? I'm not behind a proxy but when I've been running 'R CMD check' whenon very poor 3G connection, it had eventually timed out. /Henrik I am pretty sure it is a proxy issue. I looked at the check code in the tools package and it seems that the issue is in the local function `.repository_db()` (defined in `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` with argument open=rb, that hangs probably because it does not use the proxy settings. I had a similar issue with `source()`, which apparently uses internal network functions (not as download.file), but is supposed to work behind a proxy (correct?). Does anybody else have this problem? I was wondering if there is a way around, as I would like to be able to use --as-cran for my checks. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Default subset and concatenation operators for namedList
Hi, in R version 2.14.1 (2011-12-22), is it wanted that the class namedList does not overloads the '[' and 'c' operators: showMethods('c', class='namedList') showMethods('[', class='namedList') This means that if one creates a class that inherits from namedList, one has to define these operators so that they do not drop the S4 class (code below). I agree that one would probably have to define custom operators to correctly handle other possible extra slots when subsetting and concatenatiing. But it seems that namedList could at least deal with the slot `names` and not convert the object to a standard list, which is troublesome. Is there a reason why these operators are not pre-defined in namedList? Thank you. Renaud ## setClass('A', contains='namedList') a - new('A', list(a=1,b=2,c=3)) str(a) # subset converts to standard list str(a[1:2]) str(a[2:3]) # concatenation converts to standard list str(c(a, list(d=4, e=5))) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R package BibTex entries: looking for a more general solution
Indeed I broke the function when adding support for bibentry objects... By the way, let's give credits back to Ceasars: I am not the author of the bibtex package, Romain Francois is. I just contributed the write.bib function, mainly inspired by Achim's function. Romain, I will send a fix for this now. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 19/12/2011 15:56, Michael Friendly wrote: On 12/19/2011 2:02 AM, Renaud Gaujoux wrote: Hi, I actually adapted and integrated this feature into Achim's -- nice -- function (posted on r-help). Romain included it a couple of weeks ago into the bibtex package as function write.bib, and submitted the update to CRAN, but some NOTEs in the check delayed its availability on CRAN. You can still install and try out the new version with: install.packages(bibtex, repos=http://R-Forge.R-project.org;) Keys for multiple citations are generated as pkgname%i, which might not be ideal, but works ok though. It might be better not number the first (main) citation. Romain, I think I will submit a patch for this. Hope this helps. Thanks, Renaud I now have a working function, Rpackages.bib() that is roughly equivalent to your write.bib() and other related material at http://euclid.psych.yorku.ca/SCS/Private/Rbibs/ Also, see the document http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpkg-test.pdf which reports some problems perl fixes for the generated bibentries. These might be incorporated into the functions to make the resulting bibtex files directly usable. Your bibtex package seems the most natural place for this. Also, write.bib() doesn't seem to work unless you pass a list of package names. write.bib() Error in is(entry, bibentry) : argument entry is missing, with no default write.bib(NULL) Error in write.bib(NULL) : Invalid argument `entry`: expected a bibentry object or a character vector of package names. best, -Michael __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R package BibTex entries: looking for a more general solution
Hi, I actually adapted and integrated this feature into Achim's -- nice -- function (posted on r-help). Romain included it a couple of weeks ago into the bibtex package as function write.bib, and submitted the update to CRAN, but some NOTEs in the check delayed its availability on CRAN. You can still install and try out the new version with: install.packages(bibtex, repos=http://R-Forge.R-project.org;) Keys for multiple citations are generated as pkgname%i, which might not be ideal, but works ok though. It might be better not number the first (main) citation. Romain, I think I will submit a patch for this. Hope this helps. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Identify \Sexpr call?
More or less in the same vein as Henrik's post, is it possible to detect that a function is being called in an \Sexpr when generating an Rd file? Thank you -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Thank you Duncan for pointing this out. I did have tried using the command \out with no success, but I finally manage to do what I want with: \if{html}{\Sexpr[results=rd, stage=render]{out{preline\nnewline\n\nother line/pre}}} \if{text}{\Sexpr[results=rd, stage=render]{out{line\nnewline\n\nother line}}} \if{latex}{\Sexpr[results=rd, stage=render]{out{begin{verbatim}line\nnewline\n\nother lineend{verbatim The only remaining issue is with format 'text', that does not show single break lines. Double break lines are shown correctly with an empty line. This can be put in a macro: \newcommand{\rdVerb}{\if{html}{\Sexpr[results=rd, stage=render]{paste(\\out{pre,#1,/pre}, sep='')}}\if{text}{\Sexpr[results=rd, stage=render]{paste(\\out{,#1,}, sep='')}}\if{latex}{\Sexpr[results=rd,stage=render]{paste(\\out{begin{verbatim},#1,end{verbatim}}, sep='')}} } which can be used as: \rdVerb{line\nnew line\n\nother paragraph} Dynamic code works as well: \rdVerb{paste(This is the result of tools:::Rd_expr_PR(1234):, tools:::Rd_expr_PR(1234), sep=)} \rdVerb{paste(This is the result of tools:::Rd_expr_PR(1234):, tools:::Rd_expr_PR(1234), sep=\n)} But backslashes must be escaped twice: \rdVerb{\begin{section}\ntest\nsd\n\n\end{section}} Note that on the text version generated by the second \VERBATIM actually correctly shows the new line. Not sure why (?). Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 03/11/2011 18:28, Duncan Murdoch wrote: On 03/11/2011 10:49 AM, Renaud Gaujoux wrote: On 03/11/2011 16:28, Duncan Murdoch wrote: On 03/11/2011 10:21 AM, Renaud Gaujoux wrote: Thank you Georgi. With the fix \long the output is indeed consistent with the documentation. I think my use of cat() worked by luck as its output should not have been rendered. Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This would allow to generate custom Latex, or HTML code, but it might also be is hazardous... Yes, that's possible. See the manual, especially the section 2.12 conditional text. Duncan Murdoch Conditional text is possible, but latex or html code seem to be preprocessed and escaped, or maybe I am not doing the right things. Not if you ask it not to do that. See the example in that section of the manual. Duncan Murdoch To test: \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files \if{html}{\Sexpr[results=text, stage=render]{boldtext in bold/bold}} \if{text}{\Sexpr[results=text, stage=render]{_text in bold_}} \if{latex}{\Sexpr[results=text, stage=render]{textbf{text in bold}}} } %%% __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] line\nnext line i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. Besides it will also break on \Sexpr[results=verbatim, stage=render]{list(text, 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=verbatim, stage=render]{line\nnext line\n} 3: \Sexpr[results=verbatim, stage=render]{list(line\nnext line, 3)} Text: 1: \Sexpr[results=text, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=text, stage=render]{line\nnext line\n} 3: \Sexpr[results=text, stage=render]{list(line\nnext line, 3)} } % __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Although I use Latex quite a lot, I am not literate in Latex macro languages (e.g. the definition of AsIs). Is there (I am sure there is) a reason why a plain verbatim environment is not used in this case? On 03/11/2011 14:19, Duncan Murdoch wrote: On 11-11-03 7:58 AM, Renaud Gaujoux wrote: Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] line\nnext line i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} I don't think you want that: it forces display mode. You might want verbatim text displayed inline, like \verb does. Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. So the problem is with the \AsIs macro. You can see the definition in the Rd.sty file in R_HOME/share/texmf/tex/latex. Can you suggest an improvement? Duncan Murdoch Besides it will also break on \Sexpr[results=verbatim, stage=render]{list(text, 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=verbatim, stage=render]{line\nnext line\n} 3: \Sexpr[results=verbatim, stage=render]{list(line\nnext line, 3)} Text: 1: \Sexpr[results=text, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=text, stage=render]{line\nnext line\n} 3: \Sexpr[results=text, stage=render]{list(line\nnext line, 3)} } % __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Thank you Georgi. With the fix \long the output is indeed consistent with the documentation. I think my use of cat() worked by luck as its output should not have been rendered. Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This would allow to generate custom Latex, or HTML code, but it might also be is hazardous... Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 03/11/2011 15:50, Georgi Boshnakov wrote: Dear Duncan and Renauld, The error caused by the empty line(s) can be removed by prefixin the macro with \long in Rd.sty: \long\def\Rd@AsIsX#1{\normalfont #1\egroup} but the slash-n's come up in the output. In text mode this seems not to be a problem. Following normal TeX rules one needs to enter an empty line, e.g. by \n\n. Having written that, I tried putting two \n's in the verbatim text and it seems to work (see below). I need to consult the TeX book to be sure but the problem with AsIs seems to be that by the time it starts processing its argument it has been tokenized by TeX (hence single newlines have become spaces). Further thought may be needed about the new lines in verbatim. I may have missed again something but it seems that the observed output is consistent with the documentation, which states: results=verbatim Print the results of the code just as if it was executed at the console, and include the printed results verbatim. (Invisible results will not print.) And the examples print on the console as they appear in output (with print, not cat). Do we need exception from the general rule? An alternative would be to introduce results=verbatimLines option. Georgi \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat(line\n\nnext line\n\n and another)} %1a: \Sexpr[results=text, stage=render]{capture.output(cat(c(line, next line\n),sep=\n, collapse=\n))} 2: \Sexpr[results=verbatim, stage=render]{line\nnext line\n} 3: \Sexpr[results=verbatim, stage=render]{list(line\nnext line, 3)} 4: \Sexpr[results=verbatim, stage=render]{list(c(line, next line), 3)} Text: 1: \Sexpr[results=text, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=text, stage=render]{line\nnext line\n} 3: \Sexpr[results=text, stage=render]{list(line\n\nnext line newline and another, 3)} } -- Dr Georgi Boshnakov tel: (+44) (0)161 306 3684 School of Mathematics fax: (+44) (0)161 306 3669 Alan Turing Building 1.125 The University of Manchester email: georgi.boshna...@manchester.ac.uk Oxford Road Manchester M13 9PL UK From: Duncan Murdoch [murdoch.dun...@gmail.com] Sent: 03 November 2011 12:19 To: Renaud Gaujoux Cc: Georgi Boshnakov; r-devel@r-project.org Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file On 11-11-03 7:58 AM, Renaud Gaujoux wrote: Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] line\nnext line i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} I don't think you want that: it forces display mode. You might want verbatim text displayed inline, like \verb does. Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. So the problem is with the \AsIs macro. You can see the definition in the Rd.sty file in R_HOME/share/texmf/tex/latex. Can you suggest an improvement? Duncan Murdoch Besides it will also break on \Sexpr[results=verbatim, stage=render]{list(text, 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=verbatim, stage=render]{line\nnext line\n} 3: \Sexpr[results=verbatim, stage=render]{list(line\nnext line, 3)} Text: 1: \Sexpr[results=text, stage=render]{cat(line\nnext line\n)} 2: \Sexpr[results=text, stage=render]{line\nnext line\n} 3: \Sexpr[results=text, stage=render]{list(line\nnext line, 3)} } % __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
On 03/11/2011 16:33, Georgi Boshnakov wrote: Dear Renalud,, Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This may well be a clean approach. After my previous email, I looked again at the definition of thr \AsIs macro. Its purpose seems to be to typeset text containing special characters in normal text mode and thus its purpose is different from \verb and ``verbatm' macros/environments in LaTeX. Maybe using an environment such as Verbatim defined in fancyvrb would solve the problem? I think you can control the font, etc... still keeping the no formatting of plain verbatim. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Getting back to the \Sexpr issue, I tried with R-2.14.0 and I still see the following issues: - verbatim multiline is not shown properly on PDF (\Sexpr[results=verbatim, stage=render]{cat(line\nnext line)}) - verbatim with empty lines breaks PDF generation (\Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n\nyet another line)}). Would there be an issue in using a plain Latex verbatim environment for \Sexpr[results=verbatim]? - an error in an \Sexpr (\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)}) gives the following in R CMD check: * checking examples ... ERROR Error in paste(before, x, after, sep = ) : object 'exfile' not found Execution halted The two first issues can be reproduced with a call to R CMD Rd2pdf on the Rd code below. Thank you. Renaud. %%% \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop(error in sexpr)} \Sexpr[results=verbatim, stage=render]{cat(line\nnext line)} %\Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n\nyet another line)} } %%% -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: Hi, another Rd related issue I encountered is that if an error occurs in an \Sexpr in an Rd file, then on get the following error: * checking for portable compilation flags in Makevars ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking examples ... ERROR Error in paste(before, x, after, sep = ) : object 'exfile' not found Execution halted To reproduce, put a call like this in an Rd section: \Sexpr[results=verbatim, stage=render]{x- 1; stop(sexpr error)} The strange thing is that it occurs at the example checking step. Not sure why it does not break before. Thank you. Renaud PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is final, so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Thank you Duncan. I tried with: * using R version 2.14.0 RC (2011-10-24 r57417) * using platform: x86_64-unknown-linux-gnu (64-bit) But I still get the errors for verbatim multiline and the strange error if an error occurs in \Sexpr. Is your patch included in this version? I will try now with R-rc_2011-10-27_r57452.tar.gz. Renaud On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: Hi, another Rd related issue I encountered is that if an error occurs in an \Sexpr in an Rd file, then on get the following error: * checking for portable compilation flags in Makevars ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking examples ... ERROR Error in paste(before, x, after, sep = ) : object 'exfile' not found Execution halted To reproduce, put a call like this in an Rd section: \Sexpr[results=verbatim, stage=render]{x- 1; stop(sexpr error)} The strange thing is that it occurs at the example checking step. Not sure why it does not break before. Thank you. Renaud PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is final, so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
I do not see it on main CRAN home page. Do you mean http://cran.r-project.org/src/base-prerelease/R-latest.tar.gz ? On 31/10/2011 14:19, Uwe Ligges wrote: On 31.10.2011 13:13, Renaud Gaujoux wrote: Thank you Duncan. I tried with: * using R version 2.14.0 RC (2011-10-24 r57417) * using platform: x86_64-unknown-linux-gnu (64-bit) But I still get the errors for verbatim multiline and the strange error if an error occurs in \Sexpr. Is your patch included in this version? I will try now with R-rc_2011-10-27_r57452.tar.gz. Try R-2.14.0, it is already released. Or R-devel. Best, Uwe Ligges Renaud On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: Hi, another Rd related issue I encountered is that if an error occurs in an \Sexpr in an Rd file, then on get the following error: * checking for portable compilation flags in Makevars ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking examples ... ERROR Error in paste(before, x, after, sep = ) : object 'exfile' not found Execution halted To reproduce, put a call like this in an Rd section: \Sexpr[results=verbatim, stage=render]{x- 1; stop(sexpr error)} The strange thing is that it occurs at the example checking step. Not sure why it does not break before. Thank you. Renaud PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is final, so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error message library()
BTW: an ever more intuitive solution (IMHO) would be to auto-complete package names in library( ... Deepayan?;) That is non-intrusive and in line with the general use of R. (Simon) This is indeed a long wanted feature and to my surprise it actually already exists!!! (seems that Deepayan did not tell anybody about it ;) ) The help page ?completion in the utils package explains how to enable it: utils::rc.settings(ipck=TRUE) It simply worked on my Ubuntu box -- and directly went in my .Rprofile :) Hope this helps. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Output multiline verbatim in Rd files with \Sexpr in PDF manual
Hi, I want to output some generated text in verbatim in a Rd file, but do not succeed in getting it render well in all versions (text, html and pdf). I tried something like: \Sexpr[results=verbatim, stage=render]{cat(line\nnext line)} I use Rdconv to render each version of the man page. This produced the expected effect in html, but resulted in a single line line next line in the pdf and text versions. Moreover, if I add an empty line as in: \Sexpr[results=verbatim, stage=render]{cat(line\nnext line\n\nyet another line)} then the html is still correctly rendered, the text version correctly shows the empty newline (but still not the firts line break), and the pdf cannot be generated from the Latex code (because \AsIs breaks on the newline). I tried several combination of options (results=text, rd) and rd commands (\cr, \preformated) but these are always somehow escaped when generating the Latex file. Is there a way to go around these issues? Maybe I am not using the correct way. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R CMD check and error in an \Sexpr in an Rd file
Hi, another Rd related issue I encountered is that if an error occurs in an \Sexpr in an Rd file, then on get the following error: * checking for portable compilation flags in Makevars ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking examples ... ERROR Error in paste(before, x, after, sep = ) : object 'exfile' not found Execution halted To reproduce, put a call like this in an Rd section: \Sexpr[results=verbatim, stage=render]{x - 1; stop(sexpr error)} The strange thing is that it occurs at the example checking step. Not sure why it does not break before. Thank you. Renaud PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] getNativeSymbolInfo(user_unif_rand) returns different results on windows and linux
Hi, sorry to bump this post but I did not get any reply on this puzzling issue, which looks important though. While investigating the issue it came out that the value returned by getNativeSymbolInfo('user_unif_rand') (on Windows XP) seems to depend on whether it has already been called on the same symbol (see test code below. Each sequence needs to be run on on a fresh R session). Things works perfectly under Linux. Thank you for any explanation on the matter. Renaud ## SEQUENCE 1 ## library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook RESULT $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo # call again getNativeSymbolInfo getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ### RESULT $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo ## SEQUENCE 2 ## library(rstream) library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to relcuyer's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6bb84fb8 attr(,class) [1] NativeSymbol $package DLL name: rlecuyer Filename: C:/Program Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo ## SEQUENCE 3 ## ### Load library that provides a hook for user_unif_rand library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo ## ### Load other library that provides the hook library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252 [3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C [5] LC_TIME=English_South Africa.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rlecuyer_0.3-1 rstream_1.3.1 ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] getNativeSymbolInfo(user_unif_rand) returns different results on windows and linux
Hi Martin, oups... I indeed had not seen this reply (maybe I should drink less water). Thank you and sorry for the gross bump. Duncan, thank you for the work around. A cache issue makes sense as shown by the sample code in my bump-post. The cache could be updated when loading a new DLL, by looking up it symbols against the cache. Another issue is illustrated by the following calls: library(rstream) getNativeSymbolInfo(user_unif_rand, rstream) getNativeSymbolInfo(user_unif_rand, rstream) Although one specifies the package here, the results are different (see below: the first returns the complete information, the second has a NULL element package). I noticed other issues which makes very difficult to predict which DLL will actually be resolved (e.g. when one plays with loading/unloading packages that provides the hook), but I guess caching is behind all these. Renaud library(rstream) getNativeSymbolInfo(user_unif_rand, rstream) $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo getNativeSymbolInfo(user_unif_rand, rstream) $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo On 23/08/2011 17:58, Martin Morgan wrote: Hi Renaud -- did you miss this https://stat.ethz.ch/pipermail/r-devel/2011-August/061812.html ? Martin On 08/23/2011 07:40 AM, Renaud Gaujoux wrote: Hi, sorry to bump this post but I did not get any reply on this puzzling issue, which looks important though. While investigating the issue it came out that the value returned by getNativeSymbolInfo('user_unif_rand') (on Windows XP) seems to depend on whether it has already been called on the same symbol (see test code below. Each sequence needs to be run on on a fresh R session). Things works perfectly under Linux. Thank you for any explanation on the matter. Renaud ## SEQUENCE 1 ## library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook RESULT $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo # call again getNativeSymbolInfo getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ### RESULT $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo ## SEQUENCE 2 ## library(rstream) library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to relcuyer's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6bb84fb8 attr(,class) [1] NativeSymbol $package DLL name: rlecuyer Filename: C:/Program Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo ## SEQUENCE 3 ## ### Load library that provides a hook for user_unif_rand library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo ## ### Load other library that provides the hook library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ## RESULT ## $name [1] user_unif_rand $address pointer: 0x6ee41280 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252 [3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C [5] LC_TIME=English_South Africa.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rlecuyer_0.3-1 rstream_1.3.1 ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9
[Rd] R cmd check and multicore foreach loop
Hi, in R 2.12.1, R CMD check hangs when building a vignette that uses a foreach loop with the doMC parallel backend. This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. All versions of multicore, doMC and foreach are the same on both my R installations. Has anybody encountered a similar issue? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
I did notice some strange behaviour once, but things were working without a problem for a while now. foreach loops and concepts are nice concepts, which I'd like to carry on using. Maybe somebody from the foreach-dopar packages could explain why they have such issues? Tim do you have concrete examples of the issues you talked with other developers? Thank you. Renaud On 17/08/2011 12:45, Tim Triche, Jr. wrote: yes -- doMC (and doSMP) are kind of bogus and I just use multicore::mclapply() to good effect these days. I checked around with other people doing similar things at the Bioconductor developer day and pretty much everyone confirmed that doWHATEVER seems to have issues, where as multicore itself... doesn't. Just my $0.02, --t On Wed, Aug 17, 2011 at 1:45 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za mailto:ren...@mancala.cbio.uct.ac.za wrote: Hi, in R 2.12.1, R CMD check hangs when building a vignette that uses a foreach loop with the doMC parallel backend. This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. All versions of multicore, doMC and foreach are the same on both my R installations. Has anybody encountered a similar issue? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailto:R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is. John von Neumann http://www-groups.dcs.st-and.ac.uk/%7Ehistory/Biographies/Von_Neumann.html ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
hopefully you'll be able to create a reproducible example, as my hanging issues seem to come and go without any obvious reason. On 17/08/2011 13:50, Tim Triche, Jr. wrote: I'll see if I can put together a self-contained example. Primarily, the times that I use multicore (and attempted to use doSMP, mostly because one of my users refuses to ditch Windows) are when I am reading a ton of binary files, none of which depend on the others. This is a blindingly obvious use-case for e.g. doMC and doSMP, yet what typically happens is that the entire operation wedges. I'm told that doSMP really only works well with Revolution R, but per above, I will try to put together a working self-contained example to show how. On Wed, Aug 17, 2011 at 4:39 AM, Renaud Gaujoux ren...@cbio.uct.ac.za mailto:ren...@cbio.uct.ac.za wrote: I did notice some strange behaviour once, but things were working without a problem for a while now. foreach loops and concepts are nice concepts, which I'd like to carry on using. Maybe somebody from the foreach-dopar packages could explain why they have such issues? Tim do you have concrete examples of the issues you talked with other developers? Thank you. Renaud On 17/08/2011 12:45, Tim Triche, Jr. wrote: yes -- doMC (and doSMP) are kind of bogus and I just use multicore::mclapply() to good effect these days. I checked around with other people doing similar things at the Bioconductor developer day and pretty much everyone confirmed that doWHATEVER seems to have issues, where as multicore itself... doesn't. Just my $0.02, --t On Wed, Aug 17, 2011 at 1:45 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za mailto:ren...@mancala.cbio.uct.ac.za wrote: Hi, in R 2.12.1, R CMD check hangs when building a vignette that uses a foreach loop with the doMC parallel backend. This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. All versions of multicore, doMC and foreach are the same on both my R installations. Has anybody encountered a similar issue? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailto:R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is. John von Neumann http://www-groups.dcs.st-and.ac.uk/%7Ehistory/Biographies/Von_Neumann.html ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111 tel:%2B27%2021%20650%209111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### -- When you emerge in a few years, you can ask someone what you missed, and you'll find it can be summed up in a few minutes. Derek Sivers http://sivers.org/berklee ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
Uhm... maybe this is the issue. The issue seems to specially occur when I am building the vignette, which performs some parallel computations on a reduced example, therefore faster than in a normal usage of the package. The two processes (on my dual core) output some logging information using cat, which are normally sent to the console, but I guess that in the case of a vignette these are written to tex file. It is very few data though (a loop counter), so writing should be also very quick, even in a file. Could it be possible that a I/O deadlock happens because of this output? I actually use mutexes, at the end of each loop to perform bigger writing operation on a common file, but I hadn't think these would be required for the logging output, assuming that stdout and stderr were thread safe. Maybe I should use mutexes at this level too. Does multicore or doMC provide optional separate logging as doMPI does? (I guess this might be better posted to R-hpc) Thank you. Renaud On 17/08/2011 14:56, Brian G. Peterson wrote: On Wed, 2011-08-17 at 04:50 -0700, Tim Triche, Jr. wrote: I'll see if I can put together a self-contained example. Primarily, the times that I use multicore (and attempted to use doSMP, mostly because one of my users refuses to ditch Windows) are when I am reading a ton of binary files, none of which depend on the others. This is a blindingly obvious use-case for e.g. doMC and doSMP, yet what typically happens is that the entire operation wedges. I'm told that doSMP really only works well with Revolution R, but per above, I will try to put together a working self-contained example to show how. Remember that physical I/O can bind up the processes too. Having a bunch of processes all trying to read from local disk at the same time (especially when they are all trying to read the same file(s), a problem it seems you may not have) is a recipe for I/O locks that can seize up your processes. So, if the problem only occurs with physical I/O, the first thing I would try is to move that storage to a storage device on another machine that is tuned for that level of disk I/O. Regards, - Brian ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] getNativeSymbolInfo(user_unif_rand) returns different results on windows and linux
Hi, When loading a package that provides the user-supplied RNG hook user_unif_rand, calling getNativeSymbolInfo(user_unif_rand) returns informations about the loaded symbol. I am using this to identify which package currently provides the RNG hook. The results are the same on windows and linux if only one library provides the hook. If one loads a second package that provides this hook, then on linux (Ubuntu 10.10), calling again getNativeSymbolInfo(user_unif_rand) returns the latest symbol information (which I presume is the correct result). On windows (XP and Vista) however the symbol information does not change (same pointer address) and the package data is NULL. See results for both systems below. I tested this with R 2.12.1, 2.13.0 and 2.13.1 on Windows. Is this a normal behaviour for dll loaded on Windows? Thank you. Renaud # # LINUX # library(rlecuyer) getNativeSymbolInfo(user_unif_rand) $name [1] user_unif_rand $address pointer: 0x7ff55acffed0 attr(,class) [1] NativeSymbol $package DLL name: rlecuyer Filename: /home/renaud/R/x86_64-pc-linux-gnu-library/2.12/rlecuyer/libs/rlecuyer.so Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo library(rstream) getNativeSymbolInfo(user_unif_rand) $name [1] user_unif_rand $address pointer: 0x7ff55aaf58c0 attr(,class) [1] NativeSymbol $package DLL name: rstream Filename: /home/renaud/R/x86_64-pc-linux-gnu-library/2.12/rstream/libs/rstream.so Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo # # WINDOWS # library(rlecuyer) getNativeSymbolInfo(user_unif_rand) $name [1] user_unif_rand $address pointer: 0x6bb84fb8 attr(,class) [1] NativeSymbol $package DLL name: rlecuyer Filename: C:/Program Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll Dynamic lookup: TRUE attr(,class) [1] NativeSymbolInfo library(rstream) getNativeSymbolInfo(user_unif_rand) $name [1] user_unif_rand $address pointer: 0x6bb84fb8 attr(,class) [1] NativeSymbol $package NULL attr(,class) [1] NativeSymbolInfo ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R-sig-hpc] doMC - compiler - concatenate an expression vector into a single expression?
Thank you very much Steve. Your suggestion works perfectly -- at least with doSEQ, doMC and doMPI. Bests, Renaud On 28/06/2011 15:35, Stephen Weston wrote: I think that the result of the concatenation should be a call object, rather than an expression object. How about something along the lines of: '%dopar2%'- function(obj, ex) { ex- as.call(list(as.name('{'), quote({ a- i; message(Custom , a) }), substitute(ex))) do.call('%dopar%', list(obj, ex), envir=parent.frame()) } - Steve On Tue, Jun 28, 2011 at 8:26 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, this post is about foreach operators, the compiler package and the last update of doMC that includes support for the compiler functionality. I am using a home-made %dopar%-like operator that adds some custom expression to be executed before the foreach loop expression itself (see sample code below). It used to work perfectly with doMC 1.2.1, but with the introduction of the compiler functionality, things do not work properly. The change in the doMC package consists in evaluating a compiled expression instead of the original R expression: # from doMC:::doMC ... c.expr- comp(expr, env = envir, options = list(suppressUndefined = TRUE)) and for R= 2.13.0 comp is defined as compiler::compile: function (e, env = .GlobalEnv, options = NULL) { cenv- makeCenv(env) cntxt- make.toplevelContext(cenv, options) cntxt$env- addCenvVars(cenv, findLocals(e, cntxt)) genCode(e, cntxt) } environment: namespace:compiler My guess is that the function findLocals or genCode can not handle a 2-length expression vector. Maybe somebody who knows the internals of these functions could explain better this behaviour? How can I concatenate two expressions into a single one? Thank you, Renaud ## # Sample code ## `%dopar2%`- function(obj, ex){ # append custom code to the expression ex- c(expression({ a- i; message(Custom , a);}), substitute(ex)) # call the standard %dopar% operator do.call(`%dopar%`, list(obj, ex), envir=parent.frame() ) } res- foreach(i=1:3) %dopar2% { print(i); i*2; } res # # Output with doSEQ or doMC 1.2.1 # Custom 1 [1] 1 Custom 2 [1] 2 Custom 3 [1] 3 res [[1]] [1] 2 [[2]] [1] 4 [[3]] [1] 6 # # Output with doMC 1.2.2 # [[1]] expression({ a- i message(Custom , a) }, { print(i) i * 2 }) [[2]] expression({ a- i message(Custom , a) }, { print(i) i * 2 }) [[3]] expression({ a- i message(Custom , a) }, { print(i) i * 2 }) ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} ___ R-sig-hpc mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-hpc ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] doMC - compiler - concatenate an expression vector into a single expression?
Hi, this post is about foreach operators, the compiler package and the last update of doMC that includes support for the compiler functionality. I am using a home-made %dopar%-like operator that adds some custom expression to be executed before the foreach loop expression itself (see sample code below). It used to work perfectly with doMC 1.2.1, but with the introduction of the compiler functionality, things do not work properly. The change in the doMC package consists in evaluating a compiled expression instead of the original R expression: # from doMC:::doMC ... c.expr - comp(expr, env = envir, options = list(suppressUndefined = TRUE)) and for R = 2.13.0 comp is defined as compiler::compile: function (e, env = .GlobalEnv, options = NULL) { cenv - makeCenv(env) cntxt - make.toplevelContext(cenv, options) cntxt$env - addCenvVars(cenv, findLocals(e, cntxt)) genCode(e, cntxt) } environment: namespace:compiler My guess is that the function findLocals or genCode can not handle a 2-length expression vector. Maybe somebody who knows the internals of these functions could explain better this behaviour? How can I concatenate two expressions into a single one? Thank you, Renaud ## # Sample code ## `%dopar2%` - function(obj, ex){ # append custom code to the expression ex - c(expression({ a - i; message(Custom , a);}), substitute(ex)) # call the standard %dopar% operator do.call(`%dopar%`, list(obj, ex), envir=parent.frame() ) } res - foreach(i=1:3) %dopar2% { print(i); i*2; } res # # Output with doSEQ or doMC 1.2.1 # Custom 1 [1] 1 Custom 2 [1] 2 Custom 3 [1] 3 res [[1]] [1] 2 [[2]] [1] 4 [[3]] [1] 6 # # Output with doMC 1.2.2 # [[1]] expression({ a - i message(Custom , a) }, { print(i) i * 2 }) [[2]] expression({ a - i message(Custom , a) }, { print(i) i * 2 }) [[3]] expression({ a - i message(Custom , a) }, { print(i) i * 2 }) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your character slot won't identify a class reliably unless the character string has a package attribute. Look at class(x), for example, from an object from one of these classes. It will have a package attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
On 27/06/2011 14:27, Simon Urbanek wrote: On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote: On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your character slot won't identify a class reliably unless the character string has a package attribute. Look at class(x), for example, from an object from one of these classes. It will have a package attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Look at the default of where - it is the top environment, not the evaluated one, and in .onLoad the namespace is not attached yet while it is in .onAttach. Ok, but .onLoad is defined in the source of the package (i.e. within the package's namespace, am I correct?). So from what I get from the docs (copy/pasted below), isn't the top-environment supposed to be the package's namepsace, even if the package is not yet attached, and its namepace not yet in the search path? from ?isClass where: The environment in which to modify or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or name space of a package in the source for a package). When searching for class definitions, ‘where’ defines where to do the search, and the default is to search from the top-level environment or name space of the caller to this function. from ?topenv ‘topenv’ returns the first top level environment found when searching ‘envir’ and its enclosing environments. An environment is considered top level if it is the internal environment of a name space, a package environment in the search path, or ‘.GlobalEnv’. Cheers, S Possibly @John: it's a bit puzzling that isClass has a default for where yet it is entirely ignored as getClassDef is called without where. If anyone changes the default in getDeffClass() then isClass signature will be misleading - is there a practical reason for this construct? Thanks, S. ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
All is clear now. Thank you for this clarification. Cheers, Renaud On 27/06/2011 15:38, Simon Urbanek wrote: On Jun 27, 2011, at 8:43 AM, Renaud Gaujoux wrote: On 27/06/2011 14:27, Simon Urbanek wrote: On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote: On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your character slot won't identify a class reliably unless the character string has a package attribute. Look at class(x), for example, from an object from one of these classes. It will have a package attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Look at the default of where - it is the top environment, not the evaluated one, and in .onLoad the namespace is not attached yet while it is in .onAttach. Ok, but .onLoad is defined in the source of the package (i.e. within the package's namespace, am I correct?). So from what I get from the docs (copy/pasted below), isn't the top-environment supposed to be the package's namepsace, even if the package is not yet attached, and its namepace not yet in the search path? Not in this case, because where is the methods namespace (see the bottom of my last e-mail - where is not evaluated in environment of your package but in methods due to the default being removed by isClass). I would say this is a bug - changing isClass to the trivial isClass- function(Class, formal=TRUE, where = topenv(parent.frame())) !is.null(getClassDef(Class, where)) has the desired effect. Cheers, Simon from ?isClass where: The environment in which to modify or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or name space of a package in the source for a package). When searching for class definitions, ‘where’ defines where to do the search, and the default is to search from the top-level environment or name space of the caller to this function. from ?topenv ‘topenv’ returns the first top level environment found when searching ‘envir’ and its enclosing environments. An environment is considered top level if it is the internal environment of a name space, a package environment in the search path, or ‘.GlobalEnv’. Cheers, S Possibly @John: it's a bit puzzling that isClass has a default for where yet it is entirely ignored as getClassDef is called without where. If anyone changes the default in getDeffClass() then isClass signature will be misleading - is there a practical reason for this construct? Thanks, S. ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
Thank you John for your response. Things are a little bit more complicated though. The inheritance checks are not only made in .onLoad, they are part of a class validity method, which is called in .onLoad because some objects from this class are created at this stage. Such objects can also be created at any moment, not in a call from .onLoad. More or less briefly: class 'A' is in fact a virtual class defined in the package's namespace, with the purpose of defining a common interface. While the package does provide some derived classes (i.e. defined within the namespace), users too must be able to define derived classes from 'A' (i.e. not defined within the namespace). In another class from the namespace, the validity method checks that one of its character slot contains the name of a class that inherits from interface 'A'. I was just expecting `isClass` and `extends` to also work in .onLoad without specifying the argument `where` (i.e. searching everywhere, starting by the package's namespace if called within a namespace). The argument `where` being there to allow finer search. There is no argument pkgname to the validity method, to directly apply the work around. I guess I can always check the presence of the class in the some-how hard-coded namespace, and if it is not found there look for the class elsewhere: #... clref - getClass('A', .Force=TRUE, where=THE.NAMESPACE) cl - getClass(name, .Force=TRUE, where=THE.NAMESPACE) if( is.null(cl) ) cl - getClass(name, .Force=TRUE) if( !extends(cl, clref) ) return('invalid slot') #... I will use this, in last resort, although it feels strange as it will only be to deal with the case where objects are created within a call to .onLoad. I am really interested in understanding why all this: - what makes this call so different? In my sample package, if I add a call `check.classes()` directly in script.R, the classes are correctly found when the installation sources the script prepare the package for lazy loading. - why things seemed to work ok in R-2.12.1 at the installation loading check, but do not work when loading the package from an R session? Could you please briefly give some explanations or pointers? Thank you. Bests, Renaud On 23/06/2011 18:44, John Chambers wrote: The workaround is to use the package's namespace, as you did. That's one of the reasons why pkgname is an argument to .onLoad(). Depending on what you want to do, you can either use the namespace as an argument where= or get the class definition from the namespace and use it in place of the class name. A side advantage is that such checks work regardless of whether or not the classes, etc. are exported from the package. Also, on the remote chance there is another class of the same name, the check works unambiguously on your package's version. The relevant part of your script, modified accordingly, seems to work as desired. John # script.R setClass('A', representation(data='numeric')) setClass('B', contains='A') # the argument is contains= check.classes - function(where){ message(isClass('A', where = where): , methods::isClass('A', where = where)) message(isClass('B', where = where): , methods::isClass('B', where = where)) classA - getClass('A', where = where) classB - getClass('B', where = where) message(extends(classB, classA): , methods::extends(classB, classA)) } .onLoad - function(libname, pkgname=NULL){ cat(\n## .onLoad ##\n) check.classes(asNamespace(pkgname)) } .onAttach - function(libname, pkgname){ cat(\n## .onAttach ##\n) check.classes(asNamespace(pkgname)) } On 6/23/11 4:22 AM, Renaud Gaujoux wrote: Hi, I am facing with a strange behaviour of isClass and extends when these are called in .onLoad in both R 2.12.1 and R 2.13.0. This is preventing my package from doing some object initializations at a proper place (i.e. in .onLoad). Suppose one defines two S4 classes in a package, and that one needs to check the inheritance between these two when loading the package (e.g. to validate slots in objects). See package attached or code below (not sure attachments can go through). in R 2.13.0: At the loading check after installation, the classes are not found by `isClass` and `extends` when these are called in .onLoad, but are correctly found when called in .onAttach. However findClass correctly finds the class in both case, as well as isClass if it is called with the argument `where=asNamespace('THE.PACKAGE.NAME')`. When the package is loaded from an open R session, the behaviour is the same. in R 2.12.1: the classes are correctly found by isClass and extends when these are called in .onLoad or .onAttach, but only at installation (i.e. at the loading check after R CMD INSTALL). When the package is loaded from an open R session, one fails to find the classes only in .onLoad while in .onAttach they are correctly found. This is really an issue as up to now I was using .onAttach to do
[Rd] Class not found when search in .onLoad
Hi, I am facing with a strange behaviour of isClass and extends when these are called in .onLoad in both R 2.12.1 and R 2.13.0. This is preventing my package from doing some object initializations at a proper place (i.e. in .onLoad). Suppose one defines two S4 classes in a package, and that one needs to check the inheritance between these two when loading the package (e.g. to validate slots in objects). See package attached or code below (not sure attachments can go through). in R 2.13.0: At the loading check after installation, the classes are not found by `isClass` and `extends` when these are called in .onLoad, but are correctly found when called in .onAttach. However findClass correctly finds the class in both case, as well as isClass if it is called with the argument `where=asNamespace('THE.PACKAGE.NAME')`. When the package is loaded from an open R session, the behaviour is the same. in R 2.12.1: the classes are correctly found by isClass and extends when these are called in .onLoad or .onAttach, but only at installation (i.e. at the loading check after R CMD INSTALL). When the package is loaded from an open R session, one fails to find the classes only in .onLoad while in .onAttach they are correctly found. This is really an issue as up to now I was using .onAttach to do my checks and initialization, but it is not a wise thing as package that would only need to import my package (load and not attach) will not get internal objects properly initialized. All this should be done in .onLoad, but I cannot do it due to this behaviour of `extends`. Can someone provide some explanations or work around. Thank you, Renaud # script.R setClass('A', representation(data='numeric')) setClass('B', contain='A') check.classes - function(){ a - new('A') b - new('B') message(isClass('A'): , methods::isClass('A')) message(isClass('A') in namespace: , methods::isClass('A', where=asNamespace('anRpackage'))) message(findClass('A'): ) print(methods::findClass('A')) message(isClass('B'): , methods::isClass('B')) message(isClass('B') in namespace: , methods::isClass('B', where=asNamespace('anRpackage'))) message(findClass('B'): ) print(methods::findClass('B')) message(extends('B', 'A'): , methods::extends('B', 'A')) message(is(a, 'A'): , is(a, 'A')) message(inherits(a, 'A'): , inherits(a, 'A')) message(is(b, 'A'): , is(b, 'A')) } .onLoad - function(libname, pkgname=NULL){ cat(\n## .onLoad ##\n) check.classes() } .onAttach - function(libname, pkgname){ cat(\n## .onAttach ##\n) check.classes() } # Output # R-2.13.0 CMD INSTALL anRpackage_1.0.tar.gz * installing *source* package ‘anRpackage’ ... ** R ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded ## .onLoad ## isClass('A'): FALSE isClass('A') in namespace: TRUE findClass('A'): [[1]] environment: namespace:anRpackage isClass('B'): FALSE isClass('B') in namespace: TRUE findClass('B'): [[1]] environment: namespace:anRpackage extends('B', 'A'): FALSE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE ## .onAttach ## isClass('A'): TRUE isClass('A') in namespace: TRUE findClass('A'): [[1]] environment: namespace:anRpackage isClass('B'): TRUE isClass('B') in namespace: TRUE findClass('B'): [[1]] environment: namespace:anRpackage extends('B', 'A'): TRUE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE * DONE (anRpackage) # From a R-2.12.1 Console ## .onLoad ## isClass('A'): FALSE isClass('A') in namespace: TRUE findClass('A'): [[1]] environment: namespace:anRpackage isClass('B'): FALSE isClass('B') in namespace: TRUE findClass('B'): [[1]] environment: namespace:anRpackage extends('B', 'A'): FALSE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE ## .onAttach ## isClass('A'): TRUE isClass('A') in namespace: TRUE findClass('A'): [[1]] environment: namespace:anRpackage isClass('B'): TRUE isClass('B') in namespace: TRUE findClass('B'): [[1]] environment: namespace:anRpackage extends('B', 'A'): TRUE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE # R-2.12.1 CMD INSTALL anRpackage_1.0.tar.gz * installing *source* package ‘anRpackage’ ... ** R ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded ## .onLoad ## isClass('A'): TRUE isClass('A') in namespace: TRUE findClass('A'):
[Rd] Why does slot- duplicate its argument?
Hi, is there a reason why `slot-` should duplicate its argument? I am under R 2.12.1. Thank you, Renaud For example: setClass('A', representation(data='matrix')) a - new('A') x - matrix(1,2,3) tracemem(x) slot(a, 'data') - x ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Extending type list: names and inherited methods issue
Hi, I want to extend the type list, but it looks like the names are not handled properly (in the show method), not the [ method. See below for code example. I imagine this comes from the S3/S4 mixing, but I would like to understand and the recommended work around (that avoid redefining all the list methods [, $, etc...). Thank you. Bests, Renaud # define S4 class that inherits from list setClass('A', contains='list') # nothing to say when one creates an object with an unnamed list x - new('A', list(1,2,3)) x # set the names: seems ok but they are not printed names(x) - letters[1:3] names(x) x # same thing if one put the S3 .Data slot names(x@.Data) - letters[4:6] names(x) x # the subsetting works but returns a list instead of the expected object of class A class(x[1]) sessionInfo() R version 2.12.1 (2010-12-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_ZA.utf8 LC_NUMERIC=C LC_TIME=en_ZA.utf8LC_COLLATE=en_ZA.utf8 LC_MONETARY=C LC_MESSAGES=en_ZA.utf8LC_PAPER=en_ZA.utf8 [8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=CLC_MEASUREMENT=en_ZA.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Missing argument vs. empty argument
Hi, is there an easy, robust, and/or recommended way to distinguish a missing argument from an empty argument as in: foo - function(i, j){ print(missing(j)) print(nargs()) } foo(i) # TRUE, 1 foo(i,) # TRUE, 2 I know I can work around with nargs, the list of arguments and the names of the passed arguments, but I wish there is something already in place for this. This is specially important for '['-like methods where x[i,] is not the same as x[i]. What I am looking for is a function that tells me if an argument has actually been passed empty: foo - function(i, j, k){ print( empty.arg(j) ) print(nargs()) } would result in: foo(i) # FALSE, 1 foo(i, ) # TRUE, 2 foo(i, j) # FALSE, 2 foo(i, k=2) # FALSE, 2 foo(i, k=2, ) # TRUE, 3 Thank you for any help or pointer. Bests, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Missing argument vs. empty argument
My purpose is indeed to write a '[' method. I will go for the `[.data.frame` solution then. Thank you. On 25/01/2011 12:53, Prof Brian Ripley wrote: On Tue, 25 Jan 2011, Renaud Gaujoux wrote: Hi, is there an easy, robust, and/or recommended way to distinguish a missing argument from an empty argument as in: An empty argument is a missing argument when argument matching is done, e.g. foo - function(i,j) match.call() foo(i) foo(i = i) foo(i,) foo(i = i) foo(,j) foo(j = j) It is rather against the spirit of R to use the actual call rather than the matched call. Unless you are doing this to write a '[' method I would suggest you find a different convention, e.g. distinguish f(i) and f(i, NULL). For the exception, look at `[.data.frame`, which does use nargs(). (NB: what I have said does not apply to primitives like '[' itself, which do not do standard argument matching.) foo - function(i, j){ print(missing(j)) print(nargs()) } foo(i) # TRUE, 1 foo(i,) # TRUE, 2 I know I can work around with nargs, the list of arguments and the names of the passed arguments, but I wish there is something already in place for this. This is specially important for '['-like methods where x[i,] is not the same as x[i]. What I am looking for is a function that tells me if an argument has actually been passed empty: foo - function(i, j, k){ print( empty.arg(j) ) print(nargs()) } would result in: foo(i) # FALSE, 1 foo(i, ) # TRUE, 2 foo(i, j) # FALSE, 2 foo(i, k=2) # FALSE, 2 foo(i, k=2, ) # TRUE, 3 Thank you for any help or pointer. Bests, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] library: loading of required packages and argument 'lib.loc'
Hi, is there a reason why when calling the argument 'lib.loc' of library() is not used when trying to load the required packages? 0. Package A depends on package B 1. Install packages A and B in a subdirectory 'lib' of the current directory 2. Call: library(A, lib.loc='./lib') This will give something like the following: Loading required package: B Error: package 'B' could not be loaded In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called 'B' In function library there the call '.getRequiredPackages2(pkgInfo)' loads the required packages but do not pass the argument lib.loc (whereas .getRequiredPackages2 has an argument for this). I know a quick work around for this is to put './lib' into .libPaths but it would be nice if library() could do it locally (e.g. pass the argument), without changing the global settings. Thanks, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Non identical numerical results from R code vs C/C++ code?
Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? By not identical, I mean very small differences ( 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. Thank you, Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Non identical numerical results from R code vs C/C++ code?
Thank you Duncan for your reply. Currently I am using 'double' for the computations. What type should I use for extended real in my intermediate computations? The result will still be 'double' anyway right? On 10/09/2010 13:00, Duncan Murdoch wrote: On 10/09/2010 6:46 AM, Renaud Gaujoux wrote: Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? R often uses extended reals (80 bit floating point values on Intel chips) for intermediate values. C compilers may or may not do that. By not identical, I mean very small differences ( 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. Changing the order of operations will often affect rounding. For example, suppose epsilon is the smallest number such that 1 + epsilon is not equal to 1. Then 1 + (epsilon/2) + (epsilon/2) will evaluate to either 1 or 1 + epsilon, depending on the order of computing the additions. Duncan Murdoch Thank you, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Non identical numerical results from R code vs C/C++ code?
Ok. I quickly tried using LDOUBLE wherever I could, but it did not changed the results. I might try harder... I agree with you Barry, and I will re-double re-check my code. Thank you both for your help. Bests, Renaud On 10/09/2010 13:24, Barry Rowlingson wrote: On Fri, Sep 10, 2010 at 11:46 AM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? By not identical, I mean very small differences ( 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. I've had almost exactly this situation recently with an algorithm I first implemented in R and then in C. Guess what the problem was? Yes, a bug in the C code. At first I thought everything was okay because the returned values were close-ish, and I thought 'oh, rounding error', but I wasn't happy about that. So I dug a bit deeper. This is worth doing even if you are sure there no bugs in the C code (remember: there's always one more bug). First, construct a minimal dataset so you can demonstrate the problem with a manageable size of matrix. I went down to 7 data points. Then get the C to print out its inputs. Identical, and as expected? Good. Now debug intermediate calculations, printing or saving from C and checking they are the same as the intermediate calculations from R. If possible, try returning intermediate calculations in C and checking identical() with R intermediates. Eventually you will find out where the first diverge - and this is the important bit. It's no use just knowing the final answers come out different, it's likely your answer has a sensitive dependence on initial conditions. You need to track down when the first bits are different. Or it could be rounding error... Barry ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
Thanks all. Just to clarify a bit my intention with another '$'-like function. It was due to the nice features of '$': - it hides the internal implementation - it is known by most users so no extra brain-memory is required - it is quick and simple to write, which I think is actually very important as R code is often written repeatedly over and over - it allows for auto-completion - it allows dynamic structures in the sense that one can allow the user to add its own 'members' which are accessible through the same interface: 'a$custom.member', 'a$builtin.member'. I will try to work out a solution from all the suggestions I got from the list. Thanks again to all. Renaud. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 10/07/2010 17:29, Marc Schwartz wrote: On Jul 10, 2010, at 7:24 AM, Barry Rowlingson wrote: On Fri, Jul 9, 2010 at 2:10 PM, Renaud Gaujoux ren...@mancala.cbio.uct.ac.za wrote: I do not want to access the slot itself but its content: a:toto would be a...@slot1[['toto']]. The thing is that I would like to have two different methods: '$' (that I already have) and another one to define, ideally that behaves like '$'. So in brief: - a:toto would be for a...@slot1[['toto']] - a$tata would be for a...@slot2[['tata']] But apparently it might not be possible. Even if possible, definitely not desirable. As already mentioned, a:b is the sequence a to b (as in 0:10), so it's going to look weird to anyone who hasn't noticed your definition. Also, it looks fairly meaningless. By which I mean there's no obvious reason why a colon should do what you want it to do. There's also no obvious reason why a dollar sign does what it does (whats it got to do with dollars?) but we've had it for 20 years so we're stuck with it. Write a method for your objects and force your users to do a bit more typing as a trade-off for legibility: slot1(a,toto) is a lot more readable than a:toto (assuming you replace 'slot1' with something meaningful). Remember, code is most likely to be written once, and read many times - so make it easy for readers! Just to throw in another $0.02, in hindsight, not fully understanding the context of Renaud's original query, this may be a situation where implementing relevant extractor functions would make sense. Consider functions such as coef(), effects(), fitted() etc. for regression models. These allow you and your users to have functions that return components of your object class without being concerned about the internal structure of your object. Importantly, you and your users will not be affected by future changes to your object structure that you may find you have to implement over time. You simply modify the extractor functions as required when the internal structure of your class changes, so that they can be used post-change, without breaking existing code. So for example: toto(a) would return a...@slot1[['toto']] and tata(a) would return a...@slot2[['tata']]. Food for thought. Marc ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Defining a method that behaves like '$'?
Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? Thanks. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
Alright. Maybe the symbol I chose was not appropriate. I tried ':' to be able to do 'a:name' with 'a' a S4 object. I get the following error: Error in genericForPrimitive(f) : methods may not be defined for primitive function : in this version of R Does there exist any symbol that would be suitable for the job? Thanks -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:29, Duncan Murdoch wrote: On 09/07/2010 8:18 AM, Renaud Gaujoux wrote: Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? No, the parser handles a fixed syntax, and that expression is not legal. You could do it with a %$$% name using the infix operator syntax. (I think the description in the R Language Definition suggests this is not legal, since $$ is not a valid name, but it does currently work and that's unlikely to change.) Duncan Murdoch ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
I do not want to access the slot itself but its content: a:toto would be a...@slot1[['toto']]. The thing is that I would like to have two different methods: '$' (that I already have) and another one to define, ideally that behaves like '$'. So in brief: - a:toto would be for a...@slot1[['toto']] - a$tata would be for a...@slot2[['tata']] But apparently it might not be possible. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:58, Marc Schwartz wrote: You were, in effect, trying to overload the : operator, which is of course for defining sequences. If you are using S4 methods, what is wrong with using the default @ as the extraction syntax (eg. a...@name) to get at slots? See ?@ and ?slot HTH, Marc Schwartz On Jul 9, 2010, at 7:49 AM, Renaud Gaujoux wrote: Alright. Maybe the symbol I chose was not appropriate. I tried ':' to be able to do 'a:name' with 'a' a S4 object. I get the following error: Error in genericForPrimitive(f) : methods may not be defined for primitive function : in this version of R Does there exist any symbol that would be suitable for the job? Thanks -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:29, Duncan Murdoch wrote: On 09/07/2010 8:18 AM, Renaud Gaujoux wrote: Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? No, the parser handles a fixed syntax, and that expression is not legal. You could do it with a %$$% name using the infix operator syntax. (I think the description in the R Language Definition suggests this is not legal, since $$ is not a valid name, but it does currently work and that's unlikely to change.) Duncan Murdoch ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Estimate actual memory usage, not cumulative allocated
Hi, I'd like to know how estimate the memory actually used by some function call. The function essentially contains a for loop, which stops after a variable number of iterations, depending on the input data. I used Rprof with memory.profiling=TRUE, but the memory results seem to increase with the number of iterations. What I understand is that the reported memory is cumulative and based on allocation (am I right?). After each loop the same object is updated so the I'm not expecting memory usage from this part. however, the update computation itself needs to allocate memory for temporary objects, which would be the reason why the reported memory increases with the number of iterations. I just want to know the minimum amount of memory I need to run the computation, which would not be the sum of memory allocated during the computation (as some is temporary and should be released by R if necessary) How could I estimate this value? #Sample code: x - my.object for( i in 1:500 ){ # compute next value x - update(x) # stop depending on the current value if( stop(x) ) break; } Thanks, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Estimate actual memory usage, not cumulative allocated
Hi Sean, I know I'll have to optimize the memory management (maybe using the proto or R.oo packages), but for the moment I'd like to estimate the amount of memory actually used by the call. I got some estimate doing: g1 - gc(reset=TRUE) my.function(input.data) g2 - gc(); sum(g1[,6] - g2[,2]); # - sum differences between max used memory and last current used memory (merging Ncells and Vcells) Does it make sense? I was happy with it, but the thing is that it does not seem to depend on the size of the input.data, which is a matrix that is involved internally in matrix products. Even reducing the input.data from 5000 rows to 50 rows did not change the result: ~ 20 Mb for each. Something to do with the garbage collector trigger I imagine? Thanks, Renaud Sean O'Riordain wrote: Renaud, I could be wrong... but generally in R you create a new object each time you do an assignment which is why looping is slow; i.e. you're not actually updating you're creating a new version of the original. cheers, Sean On Sun, Feb 7, 2010 at 2:47 PM, Renaud Gaujoux geto...@gmail.com mailto:geto...@gmail.com wrote: Hi, I'd like to know how estimate the memory actually used by some function call. The function essentially contains a for loop, which stops after a variable number of iterations, depending on the input data. I used Rprof with memory.profiling=TRUE, but the memory results seem to increase with the number of iterations. What I understand is that the reported memory is cumulative and based on allocation (am I right?). After each loop the same object is updated so the I'm not expecting memory usage from this part. however, the update computation itself needs to allocate memory for temporary objects, which would be the reason why the reported memory increases with the number of iterations. I just want to know the minimum amount of memory I need to run the computation, which would not be the sum of memory allocated during the computation (as some is temporary and should be released by R if necessary) How could I estimate this value? #Sample code: x - my.object for( i in 1:500 ){ # compute next value x - update(x) # stop depending on the current value if( stop(x) ) break; } Thanks, Renaud __ R-devel@r-project.org mailto:R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel