Displaying 20 results from an estimated 40000 matches similar to: "Getting ... as an unevaluated list"
2006 Sep 03
2
lm, weights and ...
> lm2 <- function(...) lm(...)
> lm2(mpg ~ wt, data=mtcars)
Call:
lm(formula = ..1, data = ..2)
Coefficients:
(Intercept) wt
37.285 -5.344
> lm2(mpg ~ wt, weights=cyl, data=mtcars)
Error in eval(expr, envir, enclos) : ..2 used in an incorrect context,
no ... to look in
Can anyone explain why this is happening? (Obviously this is a
manufactured example, but it
2006 Jul 07
4
Modifying parsed code
I would like to take this:
.img(plot(1:10), filename="a")
and produce
plot(1:10)
ie. whenever .img is used, I want to take the first argument and throw
away everything else.
(I am trying to produce a Sweave like environment in which I can apply
certain functions, but not have them displayed in the output)
I think I should be able to do it using substitute, but I don't know
how
2018 Aug 13
1
substitute() on arguments in ellipsis ("dot dot dot")?
Since you're already using bang-bang ;)
library(rlang)
dots1 <- function(...) as.list(substitute(list(...)))[-1L]
dots2 <- function(...) as.list(substitute(...()))
dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]]
dots4 <- function(...) exprs(...)
bench::mark(
dots1(1+2, "a", rnorm(3), stop("bang!")),
dots2(1+2, "a",
2013 Feb 18
2
quote() vs quote(expr=)
Hi all,
I think there's a small buglet in quote:
str(quote())
# Error in quote() : 0 arguments passed to 'quote' which requires 1
str(quote(expr = ))
# symbol
I bring this up because this seems like the most natural way of
capturing the "missing" symbol with pure R code, compared to
substitute() or bquote() or formals(plot)$x
Hadley
--
Chief Scientist, RStudio
2008 Jan 04
1
checking whether the name space can be loaded with stated dependencies
Can any one provide more details on this error that I'm getting from R
CMD check:
* checking whether the name space can be loaded with stated
dependencies ... WARNING
Error in eval(expr, envir, enclos) : could not find function "proto"
Error: unable to load R code in package 'ggplot2'
Execution halted
A namespace must be able to be loaded with just the base namespace
2012 Oct 08
4
Capturing environment associated with a promise
Hi all,
It's possible to capture the expression associated with a promise
(using substitute). Is there any way to capture the environment
associated with a promise? Similarly, is there any way to tell if
something is a promise without accidentally evaluating it?
Thanks!
Hadley
--
RStudio / Rice University
http://had.co.nz/
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
On Mon, Jan 26, 2015 at 12:24 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> If it was any other environment than the global, you could use substitute:
>
> e <- new.env()
> delayedAssign("foo", stop("Hey!"), assign.env = e)
> substitute(foo, e)
>
> delayedAssign("foo", stop("Hey!"))
> substitute(foo)
Hmm... interesting
2018 May 03
2
length of `...`
On Thu, May 3, 2018 at 9:50 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 03/05/2018 11:18 AM, Duncan Murdoch wrote:
>>
>> 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"),
2004 Aug 09
1
error when calling debugger()
Hi,
I am getting an error message when I am trying to run the debugger() on
the last.dump. The debugger() stops after I make a selection. Could
someone please suggest what it might mean? The R log is included below.
This is R-1.8.1 on RH 7.3.
Thanks, Vadim
> load("last.dump.rda")
> debugger(last.dump)
Message: Error in split(x, f) : Group length is 0 but data length > 0
2010 Oct 18
1
paste an unevaluated expression
Hi R-users,
I would like to create an expression without evaluating it. Then paste
that expression to an object. Example:
Result <- paste('Result', 1, sep="")
paste(Result, substitute(apply(exp.des[1:10,], 1, one.row,
parms=parameters)), sep="<-")
However this pastes EACH element of the unevaluated expression. Instead
I just would like the expression
2013 Jul 13
1
Alternative to eval(cl, parent.frame()) ?
Dear developeRs,
I maintain a package 'pls', which has a main fit function mvr(), and
functions plsr() and pcr() which are meant to take the same arguments as
mvr() and do exactly the same, but have different default values for the
'method' argument. The three functions are all exported from the name
space.
In the 'pre namespace' era, I took inspiration from lm() and
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
2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
On Jul 15, 2015, at 12:51 PM, William Dunlap wrote:
> I think rapply() was changed to act like lapply() in this respect.
>
When I looked at the source of the difference, it was that typeof() returned 'language' in 3.2.1, while it returned 'list' in the earlier version of R. The first check in rapply's code in both version was:
if (typeof(object) != "list")
2018 Aug 13
2
substitute() on arguments in ellipsis ("dot dot dot")?
Interestingly,
as.list(substitute(...()))
also works.
On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 12/08/2018 4:00 PM, Henrik Bengtsson wrote:
>>
>> Hi. For any number of *known* arguments, we can do:
>>
>> one <- function(a) list(a = substitute(a))
>> two <- function(a, b) list(a = substitute(a), b =
2005 Dec 21
2
Newbie - Summarize function
Dear R Users,
I have searched through the archives but I am still struggling to find a
way to process the below dataset. I have a dataset that has stratum and
plot identifier. Within each plot there is variable (Top) stating the
number of measurments that should be used to to calculate the mean to the
largest "top" elements within one of the vectors (X). I would like to
process
2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
David,
If you are referring to the solution that would be:
rapply(list(test), eval, envir = fenv)
I thought I explained in the question that the above code does not work. It
does not throw an error, but the behavior is no different (at least in the
output or result). Using the above code still results in the x object not
being stored in fenv on 3.1.2.
Dayne
On Wed, Jul 15, 2015 at 4:40 PM,
2014 Feb 11
1
getting environment from "top" promise
Hi all,
It seems that there is a use case for obtaining the environment for the
"top" promise. By "top", I mean following the promise chain up the call
stack until hitting a non-promise.
S4 data containers often mimic the API of base R data structures. This
means writing S4 methods for functions that quote their arguments, like
with() and subset(). The methods package
2017 Mar 17
2
Support for user defined unary functions
Your example
x = 5
exp = parse(text="f(uq(x)) + y +z") # expression: f(uq(x)) +y + z
do_unquote(expr)
# -> the language object f(5) + y + z
could be done with the following wrapper for bquote
my_do_unquote <- function(language, envir = parent.frame()) {
if (is.expression(language)) {
# bquote does not go into expressions, only calls
2012 Jul 27
1
Version of substitute that evaluates it's first argument
Hi all,
Does there already exist a version of substitute that evaluates it's
first argument? (i.e. it accepts an already quoted expression). This
seems like something that's pretty handy, but I haven't found any
existing function to do it:
substitute_e <- function(expr, env) {
eval(substitute(substitute(expr, env), list(expr = expr)))
}
f <- quote(x + y + z)
substitute(f,
2007 Jun 08
2
wrapping lattice xyplot
This is an expanded version of the question I tried to ask last night
- I thought I had it this morning, but it's still not working and I
just do not understand what is going wrong.
What I am trying to do is write a wrapper for lattice xyplot() that
passes a whole bunch of its secondary arguments, so that I can produce
similarly formatted graphs for several different data sets. This is
what