[Rd] In the result of applying 'bquote' to function definition with 2 or more arguments, first function argument disappears (PR#14031)
Full_Name: Suharto Anggono Version: 2.8.1 OS: Windows Submission from: (NULL) (125.165.81.124) Sorry for repost. There is already PR#9602, but the problem is still there. There is also a post Re: [R] using bquote to construct function in R-help 2008-10-02. This illustrates the problem. C:\Program Files\R\R-2.8.1\binR --vanilla R version 2.8.1 (2008-12-22) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. h1 - bquote(function(x, y) { + }) h1 function(, y) { } print(h1, useSource=FALSE) function(, y) { } eval(h1) Error in eval(expr, envir, enclos) : invalid formal argument list for function h2 - bquote(function(x, y) {}) h2 function(x, y) {} print(h2, useSource=FALSE) function(, y) { } eval(h2) Error in eval(expr, envir, enclos) : invalid formal argument list for function eval(bquote(function(x) {})) function(x) {} eval(bquote(function() {})) function() {} eval(bquote(function(...) {})) function(...) {} eval(bquote(function(x, y, z) {})) Error in eval(expr, envir, enclos) : invalid formal argument list for function version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) sessionInfo() R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base R was installed from binary. Above, h1 and h2 are results of applying 'bquote' to function definition with 2 arguments. Apparently, h1 and h2 are actually the same, just printed differently. They are printed identically when useSource=FALSE. The first argument disappears, error when 'eval'-ed. But, apparently, if the function has one or zero argument, applying 'bquote' results fine. I try to debug. In the definition of 'bquote', there is 'unquote' function. bquote function (expr, where = parent.frame()) { unquote - function(e) { if (length(e) = 1) e else if (e[[1]] == as.name(.)) eval(e[[2]], where) else as.call(lapply(e, unquote)) } unquote(substitute(expr)) } environment: namespace:base unquote - function(e) { + if (length(e) = 1) e + else if (e[[1]] == as.name(.)) eval(e[[2]]) + else as.call(lapply(e, unquote)) + } h1e - substitute(function(x, y) { + }) unquote(h1e) function(, y) { } length(h1e) [1] 4 lapply(h1e, unquote) [[1]] `function` [[2]] ``(y = ) [[3]] { } [[4]] function(x, y) {(}) as.call(.Last.value) function(, y) { } h1e[[2]] $x $y unquote(h1e[[2]]) ``(y = ) length(h1e[[2]]) [1] 2 lapply(h1e[[2]], unquote) $x $y as.call(.Last.value) ``(y = ) After seeing the above result and reading the documentation of 'as.call', I conclude that the first function argument (i.e. x) is missing because of 'as.call'. It should not be applied to the result for h1e[[2]]. However, it should be applied to the result for h1e. I don't know if this is worth to be fixed. But, if not, the documentation should mention that 'bquote' is not to be applied to expression containing function definition with two or more formal arguments. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] what should NCOL(NULL) return?
Hi, I get (using r50188) nrow(NULL) NULL NROW(NULL) [1] 0 ncol(NULL) NULL NCOL(NULL) [1] 1 The last seems 'wrong' to me, though matrix(NA, 0, 1) appears to be well defined. blackhole = matrix(NA, 0, 1) blackhole[,1] = 5 blackhole [,1] h. -- +--- | Hiroyuki Kawakatsu | Business School, Dublin City University | Dublin 9, Ireland. Tel +353 (0)1 700 7496 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Help with lang4
Hi I seem to have run into a situation where I have more than 3 arguments to pass to a function from C. the following functions help me build an expression for evaluation: lang lang2 lang3 lang4 What should one do if there are more arguments than lang4 can handle? Regards Abhijit Bera [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help with lang4
Can't find the source to Rf_lang* series of functions. :| But I'm thinking it should be like this correct me if I'm wrong: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); PROTECT(SETCAR(CDR(e),portConstraints)); PROTECT(portVal=R_tryEval(e,R_GlobalEnv, NULL)); Regards Abhijit Bera On Thu, Oct 29, 2009 at 7:14 PM, Seth Falcon s...@userprimary.net wrote: On 10/29/09 7:00 AM, Abhijit Bera wrote: Hi I seem to have run into a situation where I have more than 3 arguments to pass to a function from C. the following functions help me build an expression for evaluation: lang lang2 lang3 lang4 What should one do if there are more arguments than lang4 can handle? If you take a look at the source code for those functions, something may suggest itself. R function calls at the C level are composed like in lisp: a pair-list starting with the function cons'ed with the args. + seth [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help with lang4
On 10/29/09 7:00 AM, Abhijit Bera wrote: Hi I seem to have run into a situation where I have more than 3 arguments to pass to a function from C. the following functions help me build an expression for evaluation: lang lang2 lang3 lang4 What should one do if there are more arguments than lang4 can handle? If you take a look at the source code for those functions, something may suggest itself. R function calls at the C level are composed like in lisp: a pair-list starting with the function cons'ed with the args. + seth __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help with lang4
On 29/10/2009 10:38 AM, Abhijit Bera wrote: Can't find the source to Rf_lang* series of functions. :| They're in src/include/Rinlinedfuns.h. Duncan Murdoch But I'm thinking it should be like this correct me if I'm wrong: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); PROTECT(SETCAR(CDR(e),portConstraints)); PROTECT(portVal=R_tryEval(e,R_GlobalEnv, NULL)); Regards Abhijit Bera On Thu, Oct 29, 2009 at 7:14 PM, Seth Falcon s...@userprimary.net wrote: On 10/29/09 7:00 AM, Abhijit Bera wrote: Hi I seem to have run into a situation where I have more than 3 arguments to pass to a function from C. the following functions help me build an expression for evaluation: lang lang2 lang3 lang4 What should one do if there are more arguments than lang4 can handle? If you take a look at the source code for those functions, something may suggest itself. R function calls at the C level are composed like in lisp: a pair-list starting with the function cons'ed with the args. + seth [[alternative HTML version deleted]] __ 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] what should NCOL(NULL) return?
Hiroyuki Kawakatsu wrote: Hi, I get (using r50188) nrow(NULL) NULL NROW(NULL) [1] 0 ncol(NULL) NULL NCOL(NULL) [1] 1 The last seems 'wrong' to me, though matrix(NA, 0, 1) appears to be well defined. Seems consistent with the documentation, which says: Description |nrow| and |ncol| return the number of rows or columns present in |x|. |NCOL| and |NROW| do the same treating a vector as 1-column matrix. Based on ?NCOL alone, I guess one might be able to quibble about how NULL should be treated, as the docs do describe the argument as x a vector, array or data frame. However, it's pretty common for functions that work with vectors and arrays to treat NULL the same as numeric(0). -- Tony Plate blackhole = matrix(NA, 0, 1) blackhole[,1] = 5 blackhole [,1] h. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Makevars, cc files in multiple directories
Hello, In the src folder of my R package I have a.cc b.cc f/g/x.cc my Makevars.in has all: $(SHLIB) upon installing only, a.o and b.o is build and the final dll is comprised of a.o and b.o How can I instruct $(SHLIB) to pick up its source files from all subdirectories (or maybe a subset, though here it will be all) in src ? Much thanks Saptarshi __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Makevars, cc files in multiple directories
On Thu, 29 Oct 2009, Saptarshi Guha wrote: In the src folder of my R package I have a.cc b.cc f/g/x.cc my Makevars.in has all: $(SHLIB) upon installing only, a.o and b.o is build and the final dll is comprised of a.o and b.o How can I instruct $(SHLIB) to pick up its source files from all subdirectories (or maybe a subset, though here it will be all) in src ? I have used something like the following to achieve a similar goal. Create a library (foo.a) based on its subdirectory makefile (foo_r.mk) and then have the package link with it (foo.a). HTH Makevars -- ### ### MAKEVARS ### FOODIR= ./f/g FOOSRC= $(FOODIR) FOOINCDIR = $(FOODIR)/include FOOLIBDIR = $(FOODIR) FOOLIB= -lfoo PKG_CPPFLAGS = -DNDEBUG -I$(FOOINCDIR) PKG_LIBS = -L$(FOOLIBDIR) $(FOOLIB) $(LIBM) ## ## Targets ## all: foo $(SHLIB) foo: (cd $(FOOSRC) $(MAKE) -f foo_r.mk) .PHONY: foo all foo.mk - ### ### ### Makefile for FOO library (R environment) ### ### include $(R_HOME)/etc${R_ARCH}/Makeconf AR = ar clq RANLIB = ranlib LIBRARY= foo MAJOR = 1 MINOR = 0 SRCS = x.c \ y.c \ z.c OBJS = ${SRCS:.c=.o} ## ## Targets ## all: lib$(LIBRARY).a lib$(LIBRARY).a: $(OBJS) $(RM) $@ $(AR) $@ $(OBJS) $(RANLIB) $@ clean: $(RM) *.o core *.a .PHONY: clean all -- SIGSIG -- signature too long (core dumped) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help with lang4
On 10/29/09 7:38 AM, Abhijit Bera wrote: Can't find the source to Rf_lang* series of functions. :| But I'm thinking it should be like this correct me if I'm wrong: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); PROTECT(SETCAR(CDR(e),portConstraints)); PROTECT(portVal=R_tryEval(e,R_GlobalEnv, NULL)); Perhaps I'm misunderstanding your goal, but I do not think this is correct. After this call: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); e can be visualized as: (myfunction (arg1 (arg2 (arg3 nil If you want to end up with: (myfunction (arg1 (arg2 (arg3 (arg4 nil) Then you either will want to build up the pair list from scratch or you could use some of the helpers, e.g. (all untested), SEXP last = lastElt(e); SEXP arg4Elt = lang1(arg4); SETCDR(last, arg4Elt); Reading Rinlinedfuns.h should help some. + seth __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help with lang4
On Oct 29, 2009, at 13:56 , Seth Falcon wrote: On 10/29/09 7:38 AM, Abhijit Bera wrote: Can't find the source to Rf_lang* series of functions. :| But I'm thinking it should be like this correct me if I'm wrong: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); PROTECT(SETCAR(CDR(e),portConstraints)); PROTECT(portVal=R_tryEval(e,R_GlobalEnv, NULL)); Perhaps I'm misunderstanding your goal, but I do not think this is correct. After this call: PROTECT(e=lang4(install(myfunction),arg1,arg2,arg3); e can be visualized as: (myfunction (arg1 (arg2 (arg3 nil If you want to end up with: (myfunction (arg1 (arg2 (arg3 (arg4 nil) Then you either will want to build up the pair list from scratch or you could use some of the helpers, e.g. (all untested), SEXP last = lastElt(e); SEXP arg4Elt = lang1(arg4); SETCDR(last, arg4Elt); In general, I'd avoid SETCDR -- why not use CONS/LCONS? That is the generic way to do this (I'd suggest some reading about the fundamentals of it) -- langX/listX are just convenience macros (although not really macros ..). Cheers, Simon __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] unable to compile mgcv
Thanks for your response. In the past I have build R for RHEL and it was very simple. I did not have to do anything specific for certain libraries. I do see the .tgz file (actually it is a link to the original file which has version number too). Questions [1] do I need to unzip the tgz file, make changes, and zip it back again? Or would the makefile be able to handle the unzipped directory? [2] is there a way to just compile that library only? [3] what do I do to resume the compilation of the rest of the libraries. Re-running make would likely try to build the original version of mgcv again. Thanks -- I would appreciate any document/instructions you can point me to. William Dunlap wdun...@tibco.com wrote: -Original Message- From: Chuck White [mailto:chuckwhi...@charter.net] Sent: Wednesday, October 28, 2009 3:47 PM To: r-devel@r-project.org; William Dunlap Subject: RE: [Rd] unable to compile mgcv Thanks for your response. Can you please point me to the make file where I would make this change. Thanks. If you untar src/library/Recommended/mgcv.tgz (sp?) this file will be in mgcv/src. I'm not sure of the best way to take care of it on AIX. It may be possible to #undef TRUE in include/R.h. The AIX system includes define it in many places, the most prominent of which is in types.h. If you cannot generally #undef TRUE in a global R include file then you will have to edit the C or h files in mgcv. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] parse_Rd and/or lazyload problem
I'm encountering problems when making lazy-loadable databases of the output from 'parse_Rd'. The lazy-load database is of seemingly limitless size when I try to reload it... Admittedly I am using functions that I'm not really supposed to use, which is why this isn't a bug report, but there does seem to be something strange going on; my code is very similar to code that lives inside 'tools:::.install_package_Rd_objects'. The problems occur with just-released R2.10.0 on Windows. The examples below use files which can be found at ftp://ftp.csiro.au/MarkBravington, but you'll obviously need to modify the paths. The file scrunge.Rd is just Rdiff.Rd from the 'tools' package. The file fakepack.7z should unzip to create a fake package with a DESCRIPTION file and a man directory that contains two Rd files. Transcript of first example: eglist - list( scrunge=tools:::prepare_Rd( 'd:/temp/scrunge.Rd', defines=.Platform$OS.type, stages='install', warningCalls=FALSE)) tools:::makeLazyLoadDB( eglist, 'd:/temp/ll', compress=FALSE) tools:::fetchRdDB( 'd:/temp/ll') # Error: cannot allocate vector of size 1.4 Gb The second example triggers an error with 'tools:::.install_package_Rd_objects' itself. It doesn't happen the first time, but frequently does after the Rd files have been changed. Transcript: # Make sure d:/temp/help/ is empty, then test tools:::.install_package_Rd_objects( 'd:/temp/fakepack', 'd:/temp') test tools:::fetchRdDB( 'd:/temp/help/temp') # All good. Next, I *removed* one of the two Rd files in d:/temp/fakepack/man, ... # ...deleted d:/temp/help/temp*, and tried again test tools:::.install_package_Rd_objects( 'd:/temp/fakepack', 'd:/temp') test tools:::fetchRdDB( 'd:/temp/help/temp') Warning: Reached total allocation of 1535Mb: see help(memory.size) Warning: Reached total allocation of 1535Mb: see help(memory.size) Warning: Reached total allocation of 1535Mb: see help(memory.size) Warning: Reached total allocation of 1535Mb: see help(memory.size) Error: cannot allocate vector of size 1.9 Gb # Or on other occasions I get Error: internal error -3 in R_decompress1 Mark Bravington CSIRO CMIS Hobart Australia --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = major = 2 minor = 10.0 year = 2009 month = 10 day = 26 svn rev = 50208 language = R version.string = R version 2.10.0 (2009-10-26) Windows XP (build 2600) Service Pack 2 Locale: LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252 Search Path: .GlobalEnv, ROOT, package:grDevices, package:ad, package:chstuff, package:handy2, package:tweedie, package:statmod, package:handy, package:debug, package:mvbutils, mvb.session.info, package:tools, package:tcltk, package:stats, package:graphics, package:utils, package:methods, Autoloads, package:base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel