Displaying 20 results from an estimated 1000 matches similar to: "length of `...`"
2018 May 04
1
length of `...`
The one difference I see, is the necessity to pass the dots to the function
dotlength :
dotlength <- function(...) nargs()
myfun <- function(..., someArg = 1){
n1 <- ...length()
n2 <- dotlength()
n3 <- dotlength(...)
return(c(n1, n2, n3))
}
myfun(stop("A"), stop("B"), someArg = stop("c"))
I don't really see immediately how one can
2018 May 04
0
length of `...`
>>>>> Herv? Pag?s <hpages at fredhutch.org>
>>>>> on Thu, 3 May 2018 08:55:20 -0700 writes:
> Hi,
> It would be great if one of the experts could comment on the
> difference between Hadley's dotlength and ...length? The fact
> that someone bothered to implement a new primitive for that
> when there seems to be a very
2018 May 03
3
length of `...`
Hi,
It would be great if one of the experts could comment on the
difference between Hadley's dotlength and ...length? The fact
that someone bothered to implement a new primitive for that
when there seems to be a very simple and straightforward R-only
solution suggests that there might be some gotchas/pitfalls with
the R-only solution.
Thanks,
H.
On 05/03/2018 08:34 AM, Hadley Wickham
2018 May 03
0
length of `...`
In R-3.5.0 you can use ...length():
> f <- function(..., n) ...length()
> f(stop("one"), stop("two"), stop("three"), n=7)
[1] 3
Prior to that substitute() is the way to go
> g <- function(..., n) length(substitute(...()))
> g(stop("one"), stop("two"), stop("three"), n=7)
[1] 3
R-3.5.0 also has the ...elt(n)
2018 May 03
7
length of `...`
Hi,
In some cases the number of arguments passed as ... must be determined
inside a function, without evaluating the arguments themselves. I use
the following construct:
dotlength <- function(...) length(substitute(expression(...))) - 1L
# Usage (returns 3):
dotlength(1, 4, something = undefined)
How can I define a method for length() which could be called directly on
`...`? Or is it an
2018 May 03
2
length of `...`
As of 3.5.0 the ...length() function does exactly what you are asking for.
Before that, I don't know of an easy way to get the length without
evaluation via R code. There may be one I'm not thinking of though, I
haven't needed to do this myself.
Hope that helps.
~G
On Thu, May 3, 2018 at 7:52 AM, Mark van der Loo <mark.vanderloo at gmail.com>
wrote:
> This question is
2007 Jan 28
0
"[", .local and S4 methods (was: "[" operator and indexing ambiguity)
Dear Tony,
thanks for the tip with "nargs", when suitably applied, this answers the
problem.
The behaviour of "nargs" in S4 methods has some subtleties compared to
that in normal functions, as shown in the example below. I admit that
this is what had earlier created some confusion about the semantics of
"nargs". From the perspective of "nargs" and its
2001 Apr 23
4
What happened to --desktop geom?
Hey,
I'd like to apologize in advance if this is an old issue that everyone
already dealt with in some new mechanism...
But I compiled today's CVS for the first time in a few months, and when i
tried to fire up programs/games with --desktop geom 640x480 (or any other
dimensions) I get an "unknown option --desktop" error and the "usage" list
pops up. I read the man
2013 Dec 05
0
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
2018 May 03
0
length of `...`
This question is better aimed at the r-help mailinglist as it is not about
developing R itself.
having said that,
I can only gues why you want to do this, but why not do something like this:
f <- function(...){
L <- list(...)
len <- length()
# you can stll pass the ... as follows:
do.call(someotherfunction, L)
}
-Mark
Op do 3 mei 2018 om 16:29 schreef D?nes T?th
2012 Mar 21
1
enableJIT() and internal R completions (was: [ESS-bugs] ess-mode 12.03; ess hangs emacs)
Hello,
JIT compiler interferes with internal R completions:
compiler::enableJIT(2)
utils:::functionArgs("density", '')
gives:
utils:::functionArgs("density", '')
Note: no visible global function definition for 'bw.nrd0'
Note: no visible global function definition for 'bw.nrd'
Note: no visible global function definition for 'bw.ucv'
2018 May 03
4
length of `...`
On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote:
> In R-3.5.0 you can use ...length():
> > f <- function(..., n) ...length()
> > f(stop("one"), stop("two"), stop("three"), n=7)
> [1] 3
>
> Prior to that substitute() is the way to go
> > g <- function(..., n) length(substitute(...()))
> >
2003 Oct 10
1
number of arguments in .Call function registration
I initially sent this to the biocore mailing list - but it was
suggested that r-devel would also find it interesting.
Many of us use a macro like
#define CALL_DEF(fname, nargs) { #fname, (DL_FUNC)&fname, nargs}
for use in function registration for use with .Call.
For example, using the example from R Extension manual,
if we want to register a C function myCall with three arguments, we
2009 Mar 18
1
sprintf("%d", integer(0)) aborts
In R's sprintf() if any of the arguments has length 0
the function aborts. E.g.,
> sprintf("%d", integer(0))
Error in sprintf("%d", integer(0)) : zero-length argument
> sprintf(character(), integer(0))
Error in sprintf(character(), integer(0)) :
'fmt' is not a non-empty character vector
This comes up in code like
x[nchar(x)==0] <-
2012 Dec 27
0
Suggestion: 'method' slot for expand.grid() (incl. diffs)
Dear expeRts,
The order in which the variables vary in expand.grid() is often unintuitive. I
would like to suggest a 'method' slot for expand.grid() which requires only very
little changes (100% backward compatible) and which allows one to control this
order. Please find attached diffs against R-devel.
Cheers,
Marius
### ./src/library/base/R/expand.grid.R
2002 Jun 18
1
can't find array overruns (was: help debugging segfaults)
Dear R-devel,
Last week I got several responses to my question about debugging segfaults
in my code (original post below). After I changed the S_alloc() calls to
Calloc()/Free(), the symptom was gone, but I was told to keep looking. So I
did:
o Switched to Calloc/Free. Electric Fence did not find any problem.
o Put assert(index < bound); assert(index >=0); everywhere in the C routine
2002 Jun 12
3
help debugging segfaults
(Sorry for the cross-post--- I wasn't sure which list is more
appropriate...)
Hi everyone,
I've run into segfaults when using my randomForest package on large dataset
(e.g., 100 x 15200) and large number of trees (e.g., ntree=7000 and
mtry=3000). I'm wondering if anyone can give me some hints on where to look
for the problem.
The randomForest package mainly consists of two things:
2002 Jun 12
3
help debugging segfaults
(Sorry for the cross-post--- I wasn't sure which list is more
appropriate...)
Hi everyone,
I've run into segfaults when using my randomForest package on large dataset
(e.g., 100 x 15200) and large number of trees (e.g., ntree=7000 and
mtry=3000). I'm wondering if anyone can give me some hints on where to look
for the problem.
The randomForest package mainly consists of two things:
2011 Jan 25
1
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
2016 Jan 06
0
[klibc:master] i386: remove special handling of socketcall
Commit-ID: 9b625887a59c03c244b43550b576529f209dde11
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=9b625887a59c03c244b43550b576529f209dde11
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 5 Jan 2016 16:43:50 -0800
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 5 Jan 2016 16:43:50 -0800
[klibc] i386: remove special