similar to: suggestion on method dispatch

Displaying 20 results from an estimated 4000 matches similar to: "suggestion on method dispatch"

2012 Oct 17
1
Do *not* pass '...' to NextMethod() - it'll do it for you; missing documentation, a bug or just me?
Hi, although I've done S3 dispatching for more than a decade now, I think I managed to overlook/avoid the following pitfall when using NextMethod(): If you explicitly pass argument '...' to NextMethod(), you will effectively pass those argument twice to the "next" method! EXAMPLE: foo0 <- function(...) UseMethod("foo0"); foo1 <- function(...)
2010 Nov 15
2
How to move an internal function to external keeping same environment?
Hi I have within a quite big function foo1, an internal function foo2. Now, in order to have a cleaner code, I wish to have the internal foo2 as "external". This foo2 was using arguments within the foo1 environment that were not declared as inputs of foo2, which works as long as foo2 is within foo1, but not anymore if foo2 is external, as is the case now. Now, I could add all those
2006 Jul 02
4
Test for argument in ...
Hello! Say I have a function foo1, which has argument ... to pass various arguments to foo2 i.e. foo1 <- function(x, ...) { foo2(x, ...) } Say that foo2 accepts argument arg1 and I would like to do the following: - if foo1 is called as foo1(x) then I would like to assign some value to arg1 inside foo1 before calling foo2 arg1 <- "some value" foo2(x, arg1=arg1) - if foo1 is
2006 Apr 11
2
About list to list - thanks
Thank you very much for your useful suggestions. These are exactly what I was looking for. foo <- list(foo1, foo2, foo3) lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE)) or lapply(foo, function(x) do.call('rbind', x)) Best, Muhammad Subianto On 4/11/06, Muhammad Subianto <msubianto at gmail.com> wrote: > Dear all, > I have a result my experiment
2006 Apr 11
2
About list to list
Dear all, I have a result my experiment like this below (here my toy example): foo1 <- list() foo1[[1]] <- c(10, 20, 30) foo1[[2]] <- c(11, 21, 31) foo2 <- list() foo2[[1]] <- c(100, 200, 300) foo2[[2]] <- c(110, 210, 310) foo3 <- list() foo3[[1]] <- c(1000, 2000, 3000) foo3[[2]] <- c(1100, 2100, 3100) list(foo1,foo2,foo3) The result: > list(foo1,foo2,foo3) [[1]]
2018 Apr 05
1
potential file.copy() or documentation bug when copy.date = TRUE
This is a recent R-devel. file.copy() is not vectorized if multiple destinations succeed: cat("foo1\n", file = "foo1") cat("foo2\n", file = "foo2") unlink(c("copy1", "copy2"), recursive = TRUE) file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE) #> Error in
2014 May 02
1
Authors@R: and Author field
Hi to all Authors@R: c(person("fooa","foob", role = c("aut","cre"), email = "fooa.foob@fooc.de"), person("foo1","foo2", role = c("ctb"), email = "foo1.foo2@foo3.de")) Author: fooa foob, with contributions from foo1 foo2 using r CMD check --as-cran .. (R 3.1
2012 Jul 27
1
C code validation
Dear R-devel, I'm trying to validate the results from a C function, against a (trial and tested) older R function. For reasons unknown to me, the C function seems to give different result sometimes at each trial, even with the very same data. These are the relevant outputs from R: > library(QCA) Loading required package: lpSolve > benchmark <- function(x, y) { + index <- 0
2015 Dec 17
2
Multiple IPs and hostname
Hi, I'm running postfix as SMTP-server and dovecot as IMAP-server. The server has multiple IPs, and postfix is configured that every domain is using a separate IPv4-address. Examle: foo1.com --> 11.22.33.44 foo2.com --> 22.33.44.55 foo3.com --> 33.44.55.66 bar.org --> 66.77.88.99 The hostname of the server is: mail.bar.org Now I have a request from one of my customers,
2010 Mar 15
2
Strange behavior of assign in a S4 method.
Hi the list, I define a method that want to change an object without assignation (foo(x) and not x<-foo(x)) using deparse and assign. But when the argument of the method does not match *exactly* with the definition of the generic function, assign does not work... Anything wrong? Christophe #------ Does not work ------#
2008 Mar 25
1
Passing (Optional) Arguments
Dear List: In short, I am writing a number of functions as building blocks for other functions and have some questions about scoping and passing arguments. Suppose I have functions foo1, foo2, and foo3 such that: foo1<-function(a=1,b=TRUE,c=FALSE){#do stuff}; foo2<-function(x=1,y=FALSE,z=c(1,2,3,4)){#do stuff}; foo3<-function(lambda,...){lambda*foo1()*foo2()}; I want to be able to
2014 Dec 08
2
CRAN packages mis-using \donttest : falsy
On Mon, Dec 8, 2014 at 3:32 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: [...] > Why not declare colorspace as a "Suggests:" kind of dependency? I guess that is a solution. :/ In another example in the 'disposables' package I have: \donttest{ pkg <- make_packages( foo1 = { f <- function() print("hello!") ; d <- 1:10 }, foo2 = { f
2010 Feb 10
1
How to solve: Error in * unused argument(s) ?
Hi all, For some reason, I would like to use functions bellow (see example code bellow), but instead I get the following error message: *Error in foo2(...) : unused argument(s) (arg3 = 3)* #--------------------- # example code #--------------------- foo1 <- function(arg1,...) { print(arg1) foo2(...) foo3(...) } foo2 <- function(arg2) { print(arg2) } foo3 <- function(arg3) {
2012 Nov 06
1
Depends/Imports/Suggest/Enhence
Hi the list In the DESCRIPTION file of my package foo0, I have: Depends: foo1 Imports: foo2 Suggest: foo3 Enhence: foo4 If I understand correctly, to install foo0 on my computer, I need to already have foo1, foo2, foo3. foo4 is not necessary. I my R sesssion, when I will write: library(foo0), then the package foo1 will be attach. foo2, foo3 and foo4 will not. Is that correct? But what is
2012 Nov 07
2
Correct use of Depends, Imports and ::
Dear R developers, Taking advantage of the yesterday discussion about the use of Depends/Import/Suggests/Enhances, I would like to add a related question. Let's assume, in the DESCRIPTION file of my package foo0, I have: Depends: foo1 Imports: foo2 while in the NAMESPACE file of my package I have importFrom("foo2", f2) and within my package I use the following two external
2019 Nov 28
2
Question on TBAA and optimization
TBAA Question. Please consider the following test case. ---Snip-- struct B { int b1; int b2; }; struct C { int b1; }; struct A { int a1; struct C SC; int a2; }; int foo1(struct A * Aptr, struct B* Bptr) { int *a = &Aptr->SC.b1; *a=10; Bptr->b1 = 11; return *a; } int foo2(struct A * Aptr, struct B* Bptr) { Aptr->SC.b1=10; Bptr->b1 = 11; return
2010 Mar 23
1
S4: Multiple inheritance
Hi all, Working with S4 object, I definine two class foo1 and foo2. I define '[' (resp. '[<-') for the two classes. Then I define a third class foo3 that inherit from both foo1 and foo2. Is there a way to make '[' (resp. '[<-') for foo3 inherit from '[' (resp. '[<-') for foo1 and foo2? Thanks Christophe
2000 Apr 03
1
another save/load problem, only(?) affecting ascii = TRUE (PR#507)
On all current R versions, afaik: When using save(....., ascii = TRUE), the resulting file is not always readable by load(.). The following is executable R code exhibiting two (slightly different) examples of which I have seen even more [~/R/MISC/saveload-bug.R]: ### BUG : save(..., ascii = TRUE) produces load() - unreadable files : tstf1 <- function(n = 500) { ## Purpose: ##
2006 Sep 28
3
Evaluation of defaults in functions
Hello, and sorry if this is already explained somewhere. I couldn't find anything. R (2.3.1, Windows) seems to perform some kind of lazy evaluation when evaluating defaults in function calls that, at least for me, leads to unexpected results. Consider the following, seemingly equivalent functions: > foo1 <- function(x, y=x) { + x <- 0 + y + } > foo1(1) [1] 0 > foo2
1999 Oct 10
1
substituting values into a function
Hi everybody, In Splus, the following works fine. foo1 <- function(x, const) x + const foo2 <- function(x, const) x * const const1 <- 1 const2 <- 2 foo <- substitute(function(x) { a <- foo1(x, const1) b <- foo2(a, const2) b }, list(const1=const1, const2=const2)) foo(1:3) In R, the code doesn't work, as foo is of mode "call", and