similar to: R-lang edit: deparse(1:2) is no longer a good example of the R parser's non-invertibility

Displaying 20 results from an estimated 10000 matches similar to: "R-lang edit: deparse(1:2) is no longer a good example of the R parser's non-invertibility"

2010 Feb 09
1
cbind(deparse.level=2,...) problems
Should the deparse.level=2 argument to cbind and rbind be abandoned? It is minimally documented, not used in any CRAN package, and causes some problems. E.g., (a) If a matrix input has row names but not column names cbind(deparse.level=2,...) stops. > m<-matrix(11:14,nrow=2,ncol=2,dimnames=list(Row=c("R1","R2"),Col=charact er())) > cbind(m, 101:102,
2006 Jul 24
1
deparse - width.cutoff
I have a question about "deparse" function in R What is the reason that "deparse" use an argument like "width.cutoff" ? Why the maximum cutoff is 500? I was manipulating an R formula and used "deparse". Since the length of user's formula was greater then 500, my code didnt work. thanks Johan johan Faux <johanfaux@yahoo.com> wrote: I have a
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
2011 Apr 10
1
deparse operators in expressions
Hi, I observed a slight problem in deparse(): it will add spaces around most operators except /. I wonder if this is easy to fix. I know this is quite trivial, but I will appreciate if / is not treated as an exception. Examples: > deparse(expression(1/1)) [1] "expression(1/1)" > deparse(expression(1+1)) [1] "expression(1 + 1)" > deparse(expression(1%in%1)) [1]
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
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!
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
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', +
2017 Sep 08
1
Bug: dput/deparse with named character vector inside list
Hi, I noticed some R-devel failures on CRAN on a package I maintain: https://cloud.r-project.org/web/checks/check_results_httptest.html It appears that 'dput'/'deparse' is returning an invalid object when there is a named character vector inside a list. Here is a minimal example that reproduces the issue: > z <- list(a=c(b="foo")) > str(z) List of 1 $ a: Named
2009 Nov 09
1
deparse() and the 'else' statement
Hi all, It is recommended in ?'if' that we use 'else' right after '}' instead of starting a new line, but I noticed deparse() will separate '}' and 'else' when the 'if...else' clause is used inside {...} (e.g. function body). Here is an example: ## if/else inside {} > cat(deparse(parse(text='function(){if (TRUE) {1} else {2}}')),
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 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
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, ...) >>
2012 Sep 19
2
Warning Message: In if (deparse(params[[nm]][[3]]) != "1")
I am using the gnls procedure in nlme package to fit a nonlinear model as: nl.fit<-gnls(Y ~ b0*exp(b1/X), data = data1, params=list( b0~p1+I(p1^2)+p2+I(p2^2)+p3+I(p3^2)+p5+p6 b1~p8+p2+I(p2^2)+p3+p9+p10+p11), start = c(25,0,0,0,0,0,0,0,0,-8.6,0,0,0,0,0,0,0), weights=varPower(form =~ X)
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
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
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, ...)
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
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
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' ??? ##