Re: [Rd] relist, an inverse operator to unlist
Hi all, I've written a new version of relist that includes the suggestions from Gabor and Martin: http://www.econ.upenn.edu/~clausen/computing/relist.R The leading example now looks like this: initial.param - list(mean=c(0, 1), vcov=cbind(c(1, 1), c(1, 0))) initial.param - as.relistable(initial.param) ll - function(param.vector) { param - relist(initial.param) -sum(dnorm(x, mean=param$mean, vcov=param$vcov, log=TRUE)) # note: dnorm doesn't do vcov... but I hope you get the point } optim(unlist(initial.param), ll) One thing that concerns me is that relist() needs to count how many items are in a structued object. In this version, it does that by repeatedly calling length(unlist(obj)) which is quite inefficient (O(n^2) time, where n is the depth of the structure). Is there a clean way of making this faster? I suppose relist() could return attach a length attribute to the object it returns. Apart from that, I suppose I should do these things before inclusion: * write some documentation (including pointers in unlist's docs) * write more relist methods (eg for character) What's the usual process? Email a patch to [EMAIL PROTECTED] Cheers, Andrew On Mon, May 14, 2007 at 09:53:31AM +0200, Martin Maechler wrote: Nice ideas, Gabor and Andrew. While I agree with Andrew that such a utility makes for nicer and considerably better maintainable code in examples like his, and I do like to provide inverse operator functions in R whenever sensible, OTOH, we have strived to keep R's base package as lean and clean as possible, so I think this had to go to utils. One further small proposal: I'd use class name relistable since that's what the object of this class are and hence as.relistable(). What do other R-develers think? Martin GaGr == Gabor Grothendieck [EMAIL PROTECTED] on Mon, 14 May 2007 02:54:22 -0400 writes: GaGr unlist would not attach a skeleton to every vector it GaGr returns, only the relist method of unlist would. GaGr That way just that method needs to be added and no GaGr changes to unlist itself are needed. GaGr Before applying unlist to an object you would coerce GaGr the object to class relist to force the relist GaGr method of unlist to be invoked. GaGr Here is an outline of the code: GaGr as.relist - function(x) { GaGr if (!inherits(x, relist)) class(x) - c(relist, class(x)) GaGr x GaGr } GaGr unlist.relist - function(x, ...) { GaGr y - x GaGr cl - class(y) GaGr class(y) - cl[- grep(relist, cl)] GaGr z - unlist(y) GaGr attr(z, relist) - y GaGr as.relist(z) GaGr } GaGr relist - function(x, skeleton = attr(x, relist)) { GaGr # simpler version of relist so test can be executed GaGr skeleton GaGr } GaGr # test GaGr x - list(a = 1:2, b = 3) GaGr class(as.relist(x)) GaGr unlist(as.relist(x)) GaGr relist(unlist(as.relist(x))) GaGr On 5/14/07, Andrew Clausen [EMAIL PROTECTED] wrote: Hi GaGr, Thanks for the interesting suggestion. I must confess I got lost -- is it something like this? * unlist() could attach skeleton to every vector it returns. * relist() could then use the skeleton attached to the vector to reconstruct the object. The interface might be relist - function(flesh, skeleton=attributes(flesh)$skeleton) For example: par - list(mean=c(0, 0), vcov(rbind(c(1, 1), c(1, 1 vector.for.optim - unlist(par) print(attributes(vector.optim)$skeleton)# the skeleton is stored! converted.back.again - relist(par) Some concerns: * the metadata might get lost in some applications -- although it seems to work fine with optim(). But, if we provide both interfaces (where skeleton=flesh$skeleton is the default), then there should be no problem. * would there be any bad side-effects of changing the existing unlist interface? I suppose an option like save.skeleton could be added to unlist. I expect there would be some objections to enabling this as default behaviour, as it would significantly increase the storage requirements of the output. Cheers, Andrew On Sun, May 13, 2007 at 07:02:37PM -0400, GaGr Grothendieck wrote: I suggest you define a relist class and then define an unlist method for it which stores the skeleton as an attribute. Then one would not have to specify skeleton in the relist command so relist(unlist(relist(x))) === x 1. relist(x) is the same as x except it gets an additional class relist. 2. unlist(relist(x)) invokes the relist method of unlist on relist(x) returning another relist object
Re: [Rd] relist, an inverse operator to unlist
Hi all, For reasons I can't explain, the code I posted worked in my session, but didn't work when I started a fresh one. standardGeneric() seems to get confused by defaults for missing arguments. It looks for a missing method with this code: relist - function(flesh, skeleton=attr(flesh, skeleton)) { standardGeneric(relist) } I uploaded yet another new version that adds a wrapper that seems to resolve standardGeneric()'s confusion like this: relist - function(flesh, skeleton=attr(flesh, skeleton)) { # need a wrapper, since standardGeneric gets confused by # default arguments. f - function(flesh, skeleton) standardGeneric(relist) f(flesh, skeleton) } Cheers, Andrew __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Cannot install rsprng package (PR#9697)
insert bug report here I cannot install the R package rsprng with the following error message: install.packages(rsprng) trying URL 'http://www.stathy.com/cran/src/contrib/rsprng_0.3-4.tar.gz' Content type 'application/x-tar' length 35934 bytes opened URL == downloaded 35Kb * Installing *source* package 'rsprng' ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed Try to find sprng.h ... checking how to run the C preprocessor... gcc -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... no checking for unistd.h... yes checking sprng.h usability... no checking sprng.h presence... no checking for sprng.h... no Cannot find sprng 2.0 header file. ERROR: configuration failed for package 'rsprng' ** Removing '/u22/res/fchen/packages/R-2.4.1/lib/R/library/rsprng' The downloaded packages are in /tmp/Rtmpl3MeWk/downloaded_packages Warning message: installation of package 'rsprng' had non-zero exit status in: install.packages(rsprng) Thanks for your help! Feiming Chen --please do not edit the information below-- Version: platform = sparc-sun-solaris2.9 arch = sparc os = solaris2.9 system = sparc, solaris2.9 status = major = 2 minor = 4.1 year = 2006 month = 12 day = 18 svn rev = 40228 language = R version.string = R version 2.4.1 (2006-12-18) Locale: /en_US.ISO8859-1/C/en_US.ISO8859-1/en_US.ISO8859-1/en_US.ISO8859-1/C Search Path: .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Cannot install rsprng package (PR#9697)
Please do NOT report bugs on add-on packages to r-bugs. On 19 May 2007 at 00:14, [EMAIL PROTECTED] wrote: | I cannot install the R package rsprng with the following error message: | | install.packages(rsprng) | trying URL 'http://www.stathy.com/cran/src/contrib/rsprng_0.3-4.tar.gz' | Content type 'application/x-tar' length 35934 bytes | opened URL | == | downloaded 35Kb | | * Installing *source* package 'rsprng' ... | checking for gcc... gcc [...] | checking for sprng.h... no | Cannot find sprng 2.0 header file. ^^ You need to install the sprng library first, and do it in such a way that configure for rsprng finds. There are some daemons lurking there -- if it helps, I also packaged both sprng and rsprng for Debian and you could look at the package sources via any Debian mirror. But then your task is harder anyway as you are wrestling with a real Unix flavour and its bugs^Hfeatures. Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] AIX testers needed
Hi. system(ulimit) of AIX gives back file block size. A limit of memory is `ulimit -m'. I made gcc-4.1.2 and made R-2.5.0+patched, but the problem did not happen. $ gcc-4.1 -v Using built-in specs. Target: powerpc-ibm-aix5.2.0.0 Configured with: ../configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --disable-nls --prefix=/usr/local1/gcc-4.1.2 --enable-threads --host=powerpc-ibm-aix5.2.0.0 --program-suffix=-4.1 --with-gmp=/usr/local1 --with-mpfr=/usr/local1 --enable-languages=c,c++,f95 Thread model: aix gcc version 4.1.2 $ gcc-4.1 -print-multi-lib .; pthread;@pthread ppc64;@maix64 pthread/ppc64;@[EMAIL PROTECTED] $ export OBJECT_MODE=64 $ ./configure CC=gcc-4.1 -maix64 \ F77=gfortran-4.1 -maix64 \ CXX=g++-4.1 -maix64 \ --enable-BLAS-shlib --without-iconv 2007/5/19, Jason Barnhart [EMAIL PROTECTED]: Per the request to test the latest tarball referenced below, I have built R on AIX 5.3. There is a memory issue, please see 3) below. 1) Build with --enable-BLAS-shlib option. Builds and passes make check. 2) GNU libiconv was installed; R configured *without* the --without- iconv option. Builds and passes make check. 3) Memory issue: a) Although the server possesses 8GB of RAM and system(ulimit) returns unlimited as its value, R does not have enough memory. b) This code works on R-2.4.0 on WinXP with 2GB of RAM, but fails on the AIX build. Example code: xx - matrix(rep(1e+10,1e7),nrow=1e4,ncol=1e3) tmp.df - as.data.frame(cbind(xx,xx,xx)) Error: cannot allocate vector of size 228.9 Mb gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 233035 6.3 467875 12.5 35 9.4 Vcells 10104141 77.1 31854441 243.1 30104289 229.7 4) Used gcc-4.1.2; I have not tried the native compiler. Questions: 1) Are there suggestions on how to diagnose and resolve the memory issue? I'm still building my tool chain and I am in the midst of installing gdb. 2) Regarding the build process itself, is there more documentation or results that I should forward? Thanks, -jason version _ platform powerpc-ibm-aix5.3.0.0 arch powerpc os aix5.3.0.0 system powerpc, aix5.3.0.0 status RC major 2 minor 5.0 year 2007 month 04 day22 svn rev41276 language R version.string R version 2.5.0 RC (2007-04-22 r41276) - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: R-devel@r-project.org Cc: Sheth, Jagat K [EMAIL PROTECTED]; kamil Marcinkowski [EMAIL PROTECTED]; Tiong Lim [EMAIL PROTECTED]; Eric Harley [EMAIL PROTECTED]; Matthew Beason [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, March 28, 2007 11:27 PM Subject: [Rd] AIX testers needed With much thanks to Ei-ji Nakama, R 2.5.0 alpha supports building on AIX (at least AIX 5.2 on one system). Would anyone able to test this please get the latest tarball from http://cran.r-project.org/src/base-prerelease/R-latest.tar.gz and try installing (after reading the AIX notes in R-admin.html section C.9). In particular it would be very helpful to know if 1) --enable-BLAS-shlib works (it is the default everywhere except AIX and Darwin) 2) if people succeed in installing GNU libiconv and building without needing --without-iconv. I am Cc:ing all the people I tracked down who reported attempted AIX installations in 2006 in the hope that they may still be interested. Please report success and any hints or problems in the R-devel list. -- Brian D. Ripley, [EMAIL PROTECTED] 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- EI-JI Nakama [EMAIL PROTECTED] \u4e2d\u9593\u6804\u6cbb [EMAIL PROTECTED] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel