search for: formal

Displaying 20 results from an estimated 3189 matches for "formal".

Did you mean: format
2018 Oct 06
1
Warning when calling formals() for `[`.
Hi, Thanks for the note. How would explain the following snippet taken from `formals` doc page (the code comment is also from that doc) ? ## formals returns NULL for primitive functions. Use it in combination with ## args for this case. is.primitive(`+`) formals(`+`) formals(args(`+`)) Le sam. 6 oct. 2018 ? 13:42, Rui Barradas <ruipbarradas at sapo.pt&g...
2018 Oct 06
5
Warning when calling formals() for `[`.
Hi, A short code example showing the warning might the only thing needed here: ``` > formals(args(`[`)) NULL *Warning message:In formals(fun) : argument is not a function* > is.function(`[`) [1] TRUE > is.primitive(`[`) [1] TRUE ``` Now with an other primitive: ``` > formals(args(`sum`)) $... $na.rm [1] FALSE > is.function(`sum`) [1] TRUE > is.primitive(`sum`) [1] TRU...
2003 Oct 10
1
incorrect behaviour of formals (PR#4511)
Full_Name: Jörg Polzehl Version: 1.8.0 OS: Windows XP Submission from: (NULL) (62.141.176.1) I encountered a problem when playing with the mle library and specifying negative starting values for the parameters. The reason seems to be an incorrect behaviour of function formals: glike<-function(a=1,b=1,c=1) a > formals(glike) $a [1] 1 $b [1] 1 $c [1] 1 > unlist(formals(glike)) a b c 1 1 1 > glike<-function(a=1,b=1,c= -1) a > formals(glike) $a [1] 1 $b [1] 1 $c -1 > unlist(formals(glike)) $a [1] 1 $b [1] 1 $c -1 Regards, Jörg Polzehl PS: The...
1999 Mar 29
3
problems with formals and get (PR#151)
With 0.63.3, try test <- function(){ fn <- function(a) print("hello") print(is.function(fn)) print(names(formals("fn")))} test() if fn is not quoted in the last line of test, it works properly. test <- function(){ fn <- function() print("hello") formals(fn) <- alist(a=,b=) return(fn)} formals(test()) now try with line 3 of test changed to formals(fn) <- alist(a=) Jim...
2006 Oct 13
2
bug: Editing function formals deletes the environment
First, here's the specific bug I have. Later I'll say why I care. > ls(zappo) Error in try(name) : object "zappo" not found # good. > f = function(zappo) { function(y) zappo + y } > g = f(1) > g(1) [1] 2 > formals(g) $y > formals(g)$y > formals(g)$y = 2 > g function (y = 2) zappo + y > g(1) Error in g(1) : object "zappo" not found # looks like formals strips the environment off stuff. anything I can do about this? -Alex Original question: I'm trying to change the behavio...
2007 Jun 26
1
slight anomaly in formals<- ? (PR#9758)
Hi, The R input/output after the following paragraph is from a session with version.string R version 2.4.0 Patched (2006-11-23 r39958). The last element, x$c, of x has no value and after the assignment of x to the formals of f, x$c does not become a formal argument of f. The second assignment does the job. It seems that x$c actually becomes the body of f after the first assignment. There is no problem if the body of f is not NULL (this probably explains why the second time the assignment to the formals of f works...
2010 May 23
2
possible bug in formals
Hi, I am a little bit surprised by the following output of 'formals'. Is this the intended behavior? > f <- function(a=1,b=-1) { a+b } > class(formals(f)$a) [1] "numeric" > class(formals(f)$b) [1] "call" Josef -- ----------------------------------------------------------------------------- Josef Leydold | WU (Vienna U...
2015 Feb 19
4
[LLVMdev] Parameter names in IR and debug info
Have I correctly inferred below, how I build IR and debug info for a function type and a function (value), in particular, how to supply the names of the formal parameters? To create a function in llvm IR and give names to its formal parameters, I must: 1. Build a LLVMTypeRef for the type of each formal and the function result. 2. Build a function type using LLVMFunctionType, from the results of 1. 3. Build a function (an LLVMValueRef), using LLVMAddFunc...
2016 Mar 13
1
formals(x)<- drops attributes including class
Just checking in to see whether it is intended or not that assigning new formals to a function/closure causes any attributes to be dropped: EXAMPLE: > fcn <- structure(function() {}, foo="foo", class=c("foo")) > str(fcn) function () - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 18 1 30 18 30 1 1 .. ..- attr(*, "srcfi...
2012 Jul 26
3
rep fails on pairlist
This code which has worked for years in R but fails under R-devel: > R.version.string [1] "R Under development (unstable) (2012-07-25 r59963)" > > n <- 3 > f <- function(x) {} > formals(f) <- rep(formals(f), n) ## Error in rep(formals(f), n) : replication of pairlists is defunct The message suggests that the change was intentional. Why was this functionality removed? What code should be used in its place? -- Statistics & Software Consulting GKX Group, GKX Associates In...
2024 Feb 18
1
Capturing Function Arguments
...ld be taken from the parent frame) and function(x = a, a = NULL), f() (in which case `x` defaults to `a`, which in turn defaults to NULL). I think the key here is evaluating the arguments first, then matching. This makes a lot of assumptions about the function being inspected: no NSE, no ellipsis, formals don't depend on the body, nothing weird about the environment of the function... f <- function(...) { .makemissing <- function() alist(a=)$a .ismissing <- function(x) identical(x, .makemissing()) # prepare to evaluate formals params <- formals(f0) e <- new.env(parent = en...
2016 Mar 07
2
body(NULL) <- something; ditto formals() -- should not work
I'm proposing to signal an error (from R >= 3.3.0) in such examples -- which do "work" in R 3.2.x and earlier : > f <- NULL; body(f) <- quote(sin(a+1)); f function () sin(a + 1) <environment: 0x48f9798> > g <- NULL; formals(g) <- alist(x = pi, y=); g function (x = pi, y) NULL <environment: 0x4e6dfe8> > The proposal is that the underlying C code will signal an error when such replacement functions would create a function out of "something not a function". Martin Maechler, ETH Zurich
2010 Oct 08
2
What do you call the value that represents a missing argument?
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function to add an argument with no default value, as in http://stackoverflow.com/questions/3892580/)....
2008 May 26
2
R 2.7.0: pdf() > pdf.options versus formals
Hi, I have a tiny question about the graphics change in R 2.7.0. If I write a script ? la: options(device="pdf") formals(pdf)[c("file","onefile","width","height")] <- list("~/Rplot %03d.pdf", FALSE, 8, 8) plot(3) plot(4) both plots will be written into ONE pdf file. (not two as expected) This worked fine under 2.6.x In R 2.7.0 I have to write: options(device=&...
2018 Oct 07
4
Warning when calling formals() for `[`.
...e documentation seems to be wrong. > > -pd > > >> On 6 Oct 2018, at 19:26 , Laurent Gautier <lgautier at gmail.com> wrote: >> >> Hi, >> >> A short code example showing the warning might the only thing needed here: >> >> ``` >>> formals(args(`[`)) >> NULL >> >> *Warning message:In formals(fun) : argument is not a function* >>> is.function(`[`) >> [1] TRUE >>> is.primitive(`[`) >> [1] TRUE >> ``` >> >> Now with an other primitive: >> >> ``` >>>...
2019 Jan 27
2
Missing formal definition of "declare"?
Hi, I don't find the formal definition of "declare", although it is used in ~300 hundred of places. Do I miss something? If it is not formally defined, should it be defined? Thanks. https://llvm.org/docs/LangRef.html -- Regards, Peng
2005 Apr 30
1
formals assignment now strips attributres
The assignment form of 'formals' strips attributes (or something close to that) from the values in the list. This wasn't intentional, was it? The current behavior (2.0.0 through 2.1.0 on Windows at least): > fjj <- function() x > formals(fjj) <- list(x=c(a=2, b=4)) > fjj function (x = c(2, 4)) x Pr...
2012 Aug 05
2
setMethod sometimes fails to set package slot when signature has trailing 'ANY'
...bar, signature(x="A", y="A"), function(x, y) {}) setMethod(bar, signature(x="A", y="ANY"), function(x, y) {}) the method for signature c("A", "A") contains package information > str(getMethod(bar, c("A", "A"))) Formal class 'MethodDefinition' [package "methods"] with 4 slots ..@ .Data :function (x, y) ..@ target :Formal class 'signature' [package "methods"] with 3 slots .. .. ..@ .Data : chr [1:2] "A" "A" .. .. ..@ names : chr [1:2] "x&q...
2015 Jan 29
3
[Q] Get formal arguments of my implemented S4 method
On Jan 28, 2015, at 6:37 PM, Michael Lawrence <lawrence.michael at gene.com> wrote: > At this point I would just due: > > formals(body(method)[[2L]]) > > At some point we need to figure out what to do with this .local() confusion. Agreed, definitely. The current hack is to avoid re-matching arguments on method dispatch, so a fix would need to be fairly deep in the implementation. But I don't think the expressio...
2014 Jan 19
1
formals() adds 0 to complex function arguments
Dear list, I'm facing an issue with the automated documentation of a function using roxygen2. The function has a complex-valued default argument, which is picked up by roxygen2 using formals() to generate the corresponding Usage section of the Rd file. Unfortunately, it appears that formals() reformats complex numbers. Consider the example below, test <- function(a = 1+2i){} > args(test) function (a = 1 + (0+2i)) NULL > formals(test) $a 1 + (0+2i) As a result, R CMD chec...