similar to: deparse(substitute(arg)) in C?

Displaying 20 results from an estimated 40000 matches similar to: "deparse(substitute(arg)) in C?"

2019 Jul 13
2
Mitigating Stalls Caused by Call Deparse on Error
When large calls cause errors R may stall for extended periods.? This is particularly likely to happen with `do.call`, as in this example with a 24 second stall: ??? x <- runif(1e7) ??? system.time(do.call(paste0, list(abs, x)))? # intentional error ??? ## Error in (function (..., collapse = NULL)? : ??? ##?? cannot coerce type 'builtin' to vector of type 'character' ??? ##
2019 Jul 14
2
[External] Mitigating Stalls Caused by Call Deparse on Error
Luke, thanks for considering the issue.? I would like to try to separate the problem into two parts, as I _think_ your comments address primarily part 2 below: 1. How can we avoid significant and possibly crippling ?? stalls on error with these non-standard calls. 2. What is the best way to view these non-standard calls. I agree that issue 2. requires further thought and discussion under a
2019 Jul 16
1
[External] Mitigating Stalls Caused by Call Deparse on Error
We also have a few other suggestions and wishes about backtrace storage and display on the one hand, and display of constructed calls on the other hand. Perhaps it would be better to open a different wishlist item for traceback() to keep the discussions focused? FWIW I think deparsing backtraces lazily is a great idea. Displaying 1 line per call by default in interactive sessions, while being
2008 Sep 24
1
function can permanently modify calling function via substitute?
Dear R-devel: The following code seems to allow one function to permanently modify a calling function. I did not expect this would be allowed (short of more creative gymnastics) and wonder if it is really intended. (I can see other ways to accomplish the intended task of this code [e.g. via match.call instead of substitute below] that do not trigger the problem, but I don't think that is
2009 Nov 19
3
Issue when calling deparse(substitute(x)) from C with "anonymous" R vectors ?
Dear list, When calling R from C, what appears like a spurious error can be triggered during the execution of chisq.test(x, y). This is happening when the following conditions are met: - x and y are "anonymous" C-level R vectors (they do not have a symbol), but they are protected from garbage collection - x and y are "not too small" (it was experienced as soon as they are
2011 Jan 14
2
question about deparse(substitute(...))
Dear R helpers: I like to apply deparse(substitute()) on multiple arguments to collect the names of the arguments into a character vector. I used function test.fun as below. it works when there is only one input argument. but it does not work for multiple arguements. can someone kindly help? test.fun <- function(...){deparse(substitute(...))} test.fun(x) #this works test.fun(x,y,z) # I like
2008 Jan 22
1
deparse, substitute and S4 generics
Hello everyone, I encountered the following confusing behavior of 'deparse' and 'substitute' while programming with S4 classes (see example below). It seems like the presence of '...' argument in the definition of the generic generates the problem. I have no clue why, can anyone explain that to me? Are there any "workarounds"? Thanks a lot for your time!
2013 Jan 09
1
deparse substitute
Hi, I'm writing a function that needs the input names (as characterstrings) as part of the output. With deparse(substitute( ) ) that works fine, until I replace all zeros with 0.001 (log is calculated at some time): tf <- function(input) { input[input==0] <- 0.001 ; deparse(substitute(input)) } myguess <- 42 tf(myguess) # not "myguess", but "42" Now when
2017 May 07
2
deparse(substitute(x)) fails in implied call to an S3 print method
In an implied call to an S3 print method, deparse(substitute(x)) returns "x", regardless of the name of object in .GlobalEnv, as indicated in the following: > Xnamed <- 1 > class(Xnamed) <- 'name.x' > print.name.x <- function(x, ...){ + namex <- deparse(substitute(x)) + cat('How can I get the name of x in .GlobalEnv?\n', +
2006 Jul 27
3
deparse(substitute(foo))
I see that plot.default uses deparse(substitute(x)) to extract the character name of an argument and put it on the vertical axis. Hence: foo <- 1:10 plot( foo ) will put the label "foo" on the vertical axis. However, for a function that takes a "..." list as an input, I can only extract the first argument name: x <- 1:10 y <- 10:20 foo <- function(...) {
2012 Feb 04
1
'deparse(substitute'))' then 'assign' in a S4 methods
Hi the list, I am writing a function in which I need to affect a variable on a higher level. My fnction could be: ++++++++++++++++++ fooBis <- function(x){ nameObject <- deparse(substitute(x)) print(nameObject) assign(nameObject,4,envir=parent.frame()) } > fooBis(e) [1] "e" > e [1] 4 ----------------- (to simplify, this fnction can affect only the number
2012 May 03
1
deparse(substitute(x)) on an object with S3 class
Dear list, can someone explain to me why deparse(substitute(x)) does not seem to work when x is of a user-defined S3 class? In my actual problem, my print method is part of a package, and the method is registered in the NAMESPACE, if that should make a difference. > print.testclass <- function(x,...){ xname <- deparse(substitute(x)) cat("Your object name
2017 Jan 09
2
problem with print.generic(x)deparse(substitute(x))
Hi, All: I'm having trouble getting deparse(substitute(x)) inside print.generic to consistently I'm having trouble getting a print.something to work consistently. Consider the following toy example: # Define an object of class 'dum' k <- 1 class(k) <- 'dum' str(k) # as expected # Define print.dum print.dum <- function(x, ...)
2017 Jan 09
1
problem with print.generic(x)deparse(substitute(x))
Hi, Peter et al.: On 2017-01-09 4:24 AM, peter dalgaard wrote: > On 09 Jan 2017, at 10:53 , Spencer Graves <spencer.graves at prodsyse.com> wrote: > >> # Define an object of class 'dum' >> k <- 1 >> class(k) <- 'dum' >> str(k) # as expected >> >> # Define print.dum >> print.dum <- function(x, ...) >>
2002 Sep 18
3
problem in deparse(substitute())
Hi all, I am experiencing the following quite strange (at least in my knowledge) problem in a simple function like the following: fn<-function(y,v=2){ n<-length(y) y<-y[(v+1):(n-v)] plot(y,type="l",lty=3,xlab="Time",ylab=deparse(substitute(y))) } fn(rnorm(50)) #look at the plot!!! The plot appears with numbers on the left side! If I delete the
2005 Aug 03
1
deparse(substitute(x)) and S3 methods
Dear List, I have the following function: coca <- function(x, ...) { if(is.null(class(x))) class(x) <- data.class(x) UseMethod("coca", x) } and a default method coca.default <- function(x, y, method = c("predictive", "symmetric"), reg.method = c("simpls", "eigen"), weights = NULL,
2002 Jan 23
1
Question about substitute (and eval, parse and deparse)
I would like to define a function at run-time, but I just can't make it work (please don't question why I want to do this, because that would be too much to explain). For example, I want to define the the following function foo <- function(x) { cat("Function", "foo", "was called with argument", x, ".\n") } However, I would like to
2016 Jan 04
1
deparse with parentheses for SUBSET
Hi, maybe there?s a reason for it, but the discrepancy between the handling of `[` and `$` in deparsing seems odd to me: > substitute(a[1], list(a = quote(x * y))) x * y[1] > substitute(a$b, list(a = quote(x * y))) (x * y)$b The former is still executed in the right order (`*` first, then `[`), which is not what you?d expect looking at the deparse result. Some code that shows the execution
2017 May 07
0
deparse(substitute(x)) fails in implied call to an S3 print method
On 07/05/2017 3:56 PM, Spencer Graves wrote: > In an implied call to an S3 print method, deparse(substitute(x)) returns > "x", regardless of the name of object in .GlobalEnv, as indicated in the > following: > > > > Xnamed <- 1 > > class(Xnamed) <- 'name.x' > > print.name.x <- function(x, ...){ > + namex <-
2007 Mar 23
1
substitute and S4 objects
Hi all, I don't understand why this does not what I expect : ## code start here ############## setClass("num",representation(x="numeric")) num<-function(x) new("num",x=x) add<-function(e1,e2) { cat("Computing ",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n") e1@x+e2@x }