similar to: understanding as.list(substitute(...()))

Displaying 20 results from an estimated 20000 matches similar to: "understanding as.list(substitute(...()))"

2020 Oct 06
0
understanding as.list(substitute(...()))
You need to understand what substitute() does -- see ?substitute and/or a tutorial on "R computing on the language" or similar. Here is a simple example that may clarify: > dots <- function(...) as.list(substitute(...())) > dots(log(foo)) [[1]] log(foo) ## a call, a language object > dots2 <- function(...) as.list(...) > dots2(log(foo)) Error in as.list(...) :
2020 Oct 06
3
understanding as.list(substitute(...()))
I probably need to be more specific. What confuses me is not the use of substitute, but the parenthesis after the dots. It clearly works and I can make guesses as to why but it is definitely not obvious. The following function gives the same final result but I can understand what is happening. dots <- function (...) { exprs <- substitute(list(...)) as.list(exprs[-1]) } In the
2020 Oct 06
0
understanding as.list(substitute(...()))
Hi Tim, I have also asked a similar question a couple of months ago, and someone else did the same recently, maybe on r-devel. We received no "official" response, but Deepayan Sarkar (R Core Team member) claimed that: " There is no documented reason for this to work (AFAIK), so again, I would guess this is a side-effect of the implementation, and not a API feature you should
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 =
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",
2020 Jul 15
2
installing from copr after update
I've just updated to R 4.0.2 but am unsure how to get packages from the COPR repository to update to those built under the new version of R. FI - I'm not currently using CoprManager just trying to update/install from terminal. Regards Tim [[alternative HTML version deleted]]
2018 Aug 12
3
substitute() on arguments in ellipsis ("dot dot dot")?
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 = substitute(b)) and so on. But how do I achieve the same when I have: dots <- function(...) list(???) I want to implement this such that I can do: > exprs <- dots(1+2) > str(exprs) List of 1 $ : language 1 + 2 as well as: >
2018 Aug 13
0
substitute() on arguments in ellipsis ("dot dot dot")?
Thanks all, this was very helpful. Peter's finding - dots2() below - is indeed interesting - I'd be curious to learn what goes on there. The different alternatives perform approximately the same; dots1 <- function(...) as.list(substitute(list(...)))[-1L] dots2 <- function(...) as.list(substitute(...())) dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]]
2009 Dec 07
3
savePlot for Mac and / or Linux?
Hi all, In the package rtlu, I use the function savePlot. It is convenient since it let the user decide in which graphic format he wants his graph to be export. But when I run R CMD check, I get the following message : > rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to 3}",graphName="V1") Error in savePlot(filename = nomBarplot, type = type)
2018 May 03
2
Calling the curve function with a character object converted into an expression
Hi, Down a cascade of function calls, I want to use the curve function with an expression that is a variable. For various reason, this variable must be a character object and cannot be an expression as required by the curve function. How do I convert my variable into a expression that is accepted by curve? Thanks in advance for your help. ## The following attempts do not work myf <-
2023 Nov 17
1
Regenerate news feeds?
The news feeds (e.g. https://developer.r-project.org/blosxom.cgi/R-devel/NEWS) have some stray "\abbr" floating around. Do they need generating with a more recent version of R-devel? I've run tools::Rd2txt on https://svn.r-project.org/R/trunk/doc/NEWS.Rd and r85550 does seem to remove these abberations (compared to the same function calling on an unpatched 4.3.2 where they
2024 Jul 04
1
libdeflate
Since the 4.4.0 release, R can make use of libdeflate. From the release notes: > memCompress() and memDecompress() will use the libdeflate library (https://github.com/ebiggers/libdeflate) if installed. This uses the same type of compression for type = "gzip" but is 1.5-2x faster than the system libz library on some common platforms: the speed-up may depend on the library
2024 Sep 24
1
RStudio package maintenance moved to Copr
Many thanks I?aki. Will Quarto get pulled in from your COPR automatically as well or do we need to specifically install it before/after? Also is it worth updating the "add ons" section at https://cran.r-project.org/bin/linux/fedora/ as well? Tim On 24/09/2024 12:51, I?aki Ucar wrote: > Dear all, > > With the latest release of RStudio last week (v2024.09.0+375), support
2018 May 03
0
Calling the curve function with a character object converted into an expression
Sebastian: This is somewhat arcane, perhaps even a bug (correction on this welcomed). The problem is that the "expr" argument to curve() must be an actual expression, not a call to parse that evaluates to an expression. If you look at the code of curve() you'll see why (substitute() does not evaluate expr in the code). Another simple workaround other than sticking in the eval()
2018 Feb 20
0
deparseDots to get names of all arguments?
On 21/02/18 11:36, Spencer Graves wrote: > Hi, All: > > > ????? How can I get the names of all the arguments in dots(...)? > > > ????? I'm able to get the name of the first argument but not the second: > > > > deparseDots <- function(...){ > ? deparse(substitute(...)) > } > a <- 1 > b <- 2 > deparseDots(a, b) > [1]
2018 May 03
1
Calling the curve function with a character object converted into an expression
Typo: should be NULL not NUL of course An alternative approach closer to your original attempt is to use do.call() to explicitly evaluate the expr argument: w <- "1 + x^2" do.call(curve, list(expr = parse(text = w), ylab ="y")) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus
2018 Feb 20
5
deparseDots to get names of all arguments?
Hi, All: ????? How can I get the names of all the arguments in dots(...)? ????? I'm able to get the name of the first argument but not the second: deparseDots <- function(...){ ? deparse(substitute(...)) } a <- 1 b <- 2 deparseDots(a, b) [1] "a" ????? I'd like to get c('a', 'b'). ????? Thanks, ????? Spencer Graves > sessionInfo() R
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about stopifnot(exprs=TRUE) . It actually works fine. I apologize. What I tried and was failed was stopifnot(exprs=T) . Error in exprs[[1]] : object of type 'symbol' is not subsettable The shortcut assert <- function(exprs) stopifnot(exprs = exprs) mentioned in "Warning" section of the documentation similarly fails
2019 Mar 05
2
stopifnot
Another possible shortcut definition: assert <- function(exprs) do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame())) After thinking again, I propose to use ??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p))) - It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2004 Nov 11
1
substitute/paste question for using Greek in plot titles
Hi all I am having troubles making sense of why code (1) below fails but code (2) below works. Code (1): > phi.1 <- 1 > plot(0 ~ 0, + main=substitute(paste("A vaue for ",phi," = ",phival), list(phival=phi.1)) ) Error in paste("The two deviances for ", phi, " = ", 2) : Object "phi" not found But this works: Code (2): >