Displaying 20 results from an estimated 46 matches for "withvisible".
2014 Jun 17
0
PATCH: Avoiding extra copies (NAMED bumped) with source(..., print.eval=FALSE) ...and with print.eval=TRUE?
OBJECTIVE:
To update source(..., print.eval=FALSE) to not use withVisible()
unless really needed. This avoids unnecessary increases of reference
counts/NAMED introduced by withVisible(), which in turn avoids
unnecessary memory allocations and garbage collection overhead. This
has an impact on all source():ed scripts, e.g. pre-allocation of large
matrices to save memory...
2013 Aug 14
2
Inconsistency between eval and withVisible (with patch)
R-team,
The $value element of the return value of *withVisible* does not agree with
the return value of *eval* when *withVisible* is passed a variable (symbol)
containing an expression object or anonymous code/expressions which
generates an expression object when evaluated (such as calls to *parse* or *
expression*).
I have attached a patch against the svn tr...
2015 Feb 09
1
WISH: eval() to preserve the "visibility" (now value is always visible)
...<- 2)
is effectively like
{ x <- 2; eval(2) } ,
which is effectively
{ x <- 2; 2 } .
The result is visible.
eval(expression(x <- 2))
or
eval(quote(x <- 2))
or
evalq(x <- 2)
gives the same effect as
x <- 2 .
The result is invisible.
In function 'eval2',
res <- eval(withVisible(expr), envir=envir, ...)
is effectively
res <- withVisible(expr) .
-------------------
Would it be possible to have the value of eval() preserve the
"visibility" of the value of the expression?
"PROBLEM":
# Invisible
> x <- 1
# Visible
> eval(x <- 2)
[1] 2...
2015 Feb 07
1
WISH: eval() to preserve the "visibility" (now value is always visible)
Would it be possible to have the value of eval() preserve the
"visibility" of the value of the expression?
"PROBLEM":
# Invisible
> x <- 1
# Visible
> eval(x <- 2)
[1] 2
"TROUBLESHOOTING":
> withVisible(x <- 1)
$value
[1] 1
$visible
[1] FALSE
> withVisible(eval(x <- 2))
$value
[1] 2
$visible
[1] TRUE
WORKAROUND:
eval2 <- function(expr, envir=parent.frame(), ...) {
res <- eval(withVisible(expr), envir=envir, ...)
value <- res$value
if (res$visible) value else invisible(va...
2018 Mar 20
1
WISH: Sys.setlocale() to return value invisibly
...or instance add:
Sys.setlocale("LC_COLLATE", "C")
to your .Rprofile file, it will print:
[1] "C"
at startup. The workaround is to wrap the call in invisible(), but I'd
argue that any "setter" function should return invisibly.
Some more details:
> withVisible(Sys.setlocale("LC_COLLATE", "C"))
$value
[1] "C"
$visible
[1] TRUE
> withVisible(Sys.setenv(FOO = "C"))
$value
[1] TRUE
$visible
[1] FALSE
/Henrik
2013 Jun 04
1
strange value in .Last.value
Hi all,
the .Last.value sometimes contains a strange $visible FALSE value. This
poses problems when using R with ESS (and ess-developer-mode) from
within org-mode.
>From http://permalink.gmane.org/gmane.emacs.ess.general/7299:
--8<---------------cut here---------------start------------->8---
Here is how to reproduce. Put df <- data.frame(a=1:3, b=1:3) in test.R
and then:
2007 Apr 06
2
wishlist: additional argument in R_tryEval (Rinternals.h)
...currently defined as:
R_tryEval(SEXP e, SEXP env, int *ErrorOccurred);
I'm trying to embed R in an application (basically yet another GUI),
and this has been very helpful to catch errors. It would be even more
helpful if it also gave access to the visibility flag. I can wrap this
in a call to withVisible, and that works great, but if there is an
error, traceback() contains a bunch of irrelevant levels.
It seems fairly easy to add another argument, similar to
ErrorOccurred, that is set to the visibility flag before returning. Is
this something that could be considered for addition in R-devel? A
pos...
2011 Jan 26
1
print() required sometimes in interactive use of console
Surprising behavior:
Most R users are aware that print()
must be used inside functions to gain
output on the console.
Apparently, print() is sometimes required
when interactively using the console.
For example, the followingmay be
entered into the R console with different results.
sample(1:8,8) #prints a permutation of 1 to 8
for(i in 1:5) #does not
sample(1:8,8)
2014 May 12
0
traceback does not show source line number of long calls when truncating output
...sehdngauxlkvm = 1,
mwvojdsfbqlchznegyirpkautx = 1, qwzxlnyorhegackmvubfsjtipd = 1,
ofkylhmugjvdwzscirnexptbqa = 1, sgolfwzrevpjnythbqxmdckuai = 1,
ezlfyoangrspdmihtuxkvwcbqj = 1, gjetdqkmvwxufslhcbpirnazoy = 1)
at traceback.R#8
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("traceback.R", keep.source = TRUE)
> traceback(max.lines = 2)
6: stop("this is an error") at traceback.R#1
5: a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1,
udnecprhlbgwtfjisyzoxaqmvk = 1, jcfpzqyirwotbsehdngauxlkvm = 1,...
2024 Oct 25
1
Could .Primitive("[") stop forcing R_Visible = TRUE?
? Fri, 25 Oct 2024 08:39:39 -0400
Duncan Murdoch <murdoch.duncan at gmail.com> ?????:
> Surely you or they should be the ones to run the test across all of
> CRAN?
That's fair. The question is, is there a fundamental reason I
overlooked to deny such a change? Except for positioning and
whitespace, the line has been in names.c since SVN revision 2. The
one regression test touched
2016 Nov 15
2
Missing objects using dump.frames for post-mortem debugging of crashed batch jobs. Bug or gap in documentation?
...bal"
f <- function(p) {
l <- "local"
dump.frames()
}
f("parameter")
results in
# > debugger()
# Message: object 'server' not foundAvailable environments had calls:
# 1: source("~/.active-rstudio-document", echo = TRUE)
# 2: withVisible(eval(ei, envir))
# 3: eval(ei, envir)
# 4: eval(expr, envir, enclos)
# 5: .active-rstudio-document#9: f("parameter")
#
# Enter an environment number, or 0 to exit
# Selection: 5
# Browsing in the environment with call:
# .active-rstudio-document#9: f("parameter&q...
2024 Oct 25
1
[External] Re: Could .Primitive("[") stop forcing R_Visible = TRUE?
...erpreted and the compiled execution paths.
However: it looks like the byte code engine implementation for the
extraction instructions does not set the visible flag for a successful
dispatch. A simple example:
x <- structure(1, class = "foo")
`[.foo` <- function(x, i) invisible(2)
withVisible(x[1])
## $value
## [1] 2
##
## $visible
## [1] TRUE
withVisible(eval(compiler::compile(quote(x[1]))))
## $value
## [1] 2
## $visible
## [1] FALSE
So there is a discrepancy between interpreted and compiled code which
is a bug that ideally should be resolved. I suspect changing the
compiled code...
2018 Feb 06
1
gdistance::shortestPath throws error "not a symmetric matrix"
...c("passage(conduct_Tobler, origin =sites at coords[5, ], goal = sites at coords[3, ", " ])"),
c("passage(conduct_Tobler, origin = sites at coords[5, ], goal = sites at coords[3, ", " ])"),
"eval(ei, envir)", "eval(ei, envir)",
"withVisible(eval(ei, envir))",
"source(\"./Skript.R\")")
Is that enough for anyone to point me in the right direction?
I am aware that this question would be probably better posted on
r-sig-geo, but as I am just an HPC janitor trying to help a customer and
am not a geo-scientist my...
2013 Mar 19
1
source, sys.source and error line numbers
...9;)
+ # another good line
+ b <- 2
+ ", file=codefile)
> # with source() the line number is displayed
> source(codefile)
Error in eval(expr, envir, enclos) : an error
> traceback()
5: stop("an error") at file46641af8754#5
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source(codefile)
> tryCatch(source(codefile), error= function(e){ str(e) })
List of 2
$ message: chr "an error"
$ call : language eval(expr, envir, enclos)
- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
&...
2016 Sep 02
4
withAutoprint({ .... }) ?
...ates, this is another case, where it would be
very convenient to have a function
withAutoprint()
so the OP could have (hopefully) have used
withAutoprint(source(..))
though that would have been equivalent to the already nicely existing
source(.., print.eval = TRUE)
which works via the withVisible(.) utility that returns for each
'expression' if it would auto print or not, and then does print (or
not) accordingly.
My own use cases for such a withAutoprint({...})
are demos and examples, sometimes even package tests which I want to print:
Assume I have a nice demo / example on a help...
2007 Jan 18
0
Emulating a REPL in frontends
...There does not seem to be a good way (from the C-API) to do auto-printing of
values outside of R_ReplDLLdo1(): R_Visible is not exported any longer, and
PrintValueEnv() is neither. Rf_PrintValue() should yield the same results as
PrintValueEnv() in most, but probably not all cases.
- From R API, withVisible() provides a way to emulate auto-printing, but with
the drawback that wrapping all statements inside withVisible() makes
potential errors harder to read (you get something like "Error in
eval.with.vis(x, parent.frame(), baseenv()) :", unless using extra magic to
convert the Error magi...
2015 Dec 18
1
Assistance much appreciated
...tz), format, usetz, ...)
2: structure(format.POSIXlt(as.POSIXlt(x, tz), format, usetz,
...), names = names(x))
3: format.POSIXct(Sys.time(), "%Y-%m-%d at %H:%M:%S")
4: format(Sys.time(), "%Y-%m-%d at %H:%M:%S")
5: eval(expr, envir, enclos)
6: eval(expr, env)
7: withVisible(eval(expr, env))
8: doTryCatch(return(expr), name, parentenv, handler)
9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
11: tryCatch(withVisible(eval(expr, env)), error = function(e) e)
12: evalWithOpt(ce, options, env)
13: processRdChu...
2012 Jan 11
2
Vegan(ordistep) error: Error in if (aod[1, 5] <= Pin) { : missing value where TRUE/FALSE needed
...9: ordistep(myrda0, scope = formula(myrda1), direction = "both",
Pin = 0.05, Pout = 0.1) at
RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
8: eval(expr, envir, enclos) at RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
7: eval(expr, pf) at RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
6: withVisible(eval(expr, pf)) at
RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
5: evalVis(expr) at RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
4: capture.output(ordistep(myrda0, scope = formula(myrda1), direction =
"both",
Pin = 0.05, Pout = 0.1)) at
RDAPARTIALSexandAgeConnectandGEOGraphy2.R#86
3...
2016 Nov 15
0
Missing objects using dump.frames for post-mortem debugging of crashed batch jobs. Bug or gap in documentation?
..."local"
> dump.frames()
> }
> f("parameter")
>
> results in
> # > debugger()
> # Message: object 'server' not foundAvailable environments had calls:
> # 1: source("~/.active-rstudio-document", echo = TRUE)
> # 2: withVisible(eval(ei, envir))
> # 3: eval(ei, envir)
> # 4: eval(expr, envir, enclos)
> # 5: .active-rstudio-document#9: f("parameter")
> #
> # Enter an environment number, or 0 to exit
> # Selection: 5
> # Browsing in the environment with call:
> # .active...
2016 Sep 02
1
withAutoprint({ .... }) ?
...gt;
>> withAutoprint()
>>
>> so the OP could have (hopefully) have used
>> withAutoprint(source(..))
>> though that would have been equivalent to the already nicely existing
>>
>> source(.., print.eval = TRUE)
>>
>> which works via the withVisible(.) utility that returns for each
>> 'expression' if it would auto print or not, and then does print (or
>> not) accordingly.
>>
>> My own use cases for such a withAutoprint({...})
>> are demos and examples, sometimes even package tests which I want to
>>...