Displaying 20 results from an estimated 20000 matches similar to: "how to determine if a function's result is invisible"
2000 Jun 30
1
dim(a <- ...) sets invisible flag erronously (PR#587)
{Nothing really harmful; R 1.1.0}
dim(.) sets (or doesn't clear) the ``invisible flag'' for printing in
certain circumstances:
> dim(a <- cbind(1))
>
does *not* print as it should :
> dim(a)
[1] 1 1
---
Question to the real "hackers" :
How can I check this using R code alone (not using files),
i.e. (how) can I ask an R expression if its
1997 Nov 06
1
R-alpha: "invisible" (yet again): a more problematic bug[let]
I think this is a more problematic buglet
in (implicit/explicit) ``invisible behavior'').
Try this (all versions of R from 0.49 to 0.60):
test0 <- function() c(1,2)
test <- function(two = FALSE) c(1, if(two) 2)
testR <- function(two = FALSE) return(c(1, if(two) 2))
test0()# 1 2 as it should
test() #
2024 Oct 24
1
Could .Primitive("[") stop forcing R_Visible = TRUE?
Hello,
The "[" primitive operator currently has the 'eval' flag set to 0 in
src/main/names.c. This means that the result of subsetting, whether
R-native or implemented by a method, will never be invisible().
This is a very reasonable default: if the user goes as far as to subset
a value, they probably want to see the result. Unfortunately, there
also exists at least one
2006 Aug 11
2
invisible() - does not return immediately as return() does
Hi,
I stumbled across the following (unexpected for me) behavior after
replacing a return() statement in the middle of a function by invisible().
Example:
foo <- function() { cat("before\n"); return(); cat("after\n")}
>foo()
before
NULL
foo2 <- function() { cat("before\n"); invisible(TRUE); cat("after\n")}
>foo2()
before
after
I expected
2011 Jul 07
4
Return invisible list
Hi, I'm new to R. I'm trying to do some extreme value theory analysis,
looking at the Mean Excess Plot of a series. These are the commands I type
to get the plot:
x=read.table("data.txt",header=T)
goa=(x[,3])
meplot(goa)
I can see the plot, but I would like to see the values of the x and y axis.
According to this page
2004 Mar 18
12
substitute question
Consider the following example:
# substitute a with b in the indicated function. Seems to work.
> z <- substitute( function()a+1, list(a=quote(b)) )
> z
function() b + 1
# z is an object of class call so use eval
# to turn it into an object of class expression; however,
# when z is evaluated, the variable a returns.
> eval(z)
function()a+1
Why did a suddenly reappear again
2024 Mar 26
1
Printout and saved results
Just FYI, the R interpreter typically saves the last value returned briefly
in a variable called .Last.value that can be accessed before you do anything
else.
> sin(.5)
[1] 0.4794255
> temp <- .Last.value
> print(temp)
[1] 0.4794255
> sin(.666)
[1] 0.6178457
> .Last.value
[1] 0.6178457
> temp
[1] 0.4794255
> invisible(sin(0.2))
> .Last.value
[1] 0.1986693
So perhaps if
2012 Dec 11
1
Debian packaging and openblas related crash when profiling in R
Hello R-sig-debian and (hopefully) Dirk:
On Debian wheezy, I have the R packaging that CRAN (you) provide. I
run into a little trouble while trying to fiddle with alternative
BLAS.
I know you and I went around on this last year and I think perhaps
I've found something wrong in the framework, or I've just done
something wrong.
I installed the packages openblas-base and openblas-dev, and
2019 May 16
3
print.<strorageMode>() not called when autoprinting
In R-3.6.0 autoprinting was changed so that print methods for the storage
modes are not called when there is no explicit class attribute. E.g.,
% R-3.6.0 --vanilla --quiet
> print.function <- function(x, ...) { cat("Function with argument list ");
cat(sep="\n ", head(deparse(args(x)), -1)); invisible(x) }
> f <- function(x, ...) { sum( x * seq_along(x) ) }
2004 May 25
3
accessing function arguments as text, macro style
Hi. In a case like this, I can get strip headings that have the name
"c" and the value for c.
d <- data.frame(a=1:5,b=6:10,c=11:15)
> xyplot(a ~ b | paste("c", c), data=d)
>
For more complicated examples, instead of using paste repeatedly I
would like to use a function. It seems like what I really want is a
macro, though. I'm not quite familiar enough
2006 Mar 01
1
stopifnot() suggestion
If an expression is passed to stopifnot() which contains missing values,
then the resulting error message is somewhat baffling until you are used
to it, e.g.
> x <- y <- rep(TRUE, 10)
> y[7] <- NA
> stopifnot(x, y)
Error in if (!(is.logical(r <- eval(ll[[i]])) && all(r)))
stop(paste(deparse(mc[[i + :
missing value where TRUE/FALSE needed
A minor change to
2005 Feb 10
2
rewrite of scatter.smooth to handle NAs
I rewrote scatter.smooth to handle missing values, but I have a question
about a move I had to make. Here's the code:
Mscatter.smooth<-function (x, y, span = 2/3, degree = 1, family =
c("symmetric",
"gaussian"), xlab = deparse(substitute(x)), ylab =
deparse(substitute(y)),
ylim = range(y, prediction$y), evaluation = 50, ...)
{
if (inherits(x,
2018 Mar 20
1
WISH: Sys.setlocale() to return value invisibly
Contrary to, say, Sys.setenv(), Sys.setlocale() returns it's value
visibly. This means that if you for 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:
1997 Nov 07
0
R-alpha: "invisible" : R_INVISIBLE .. -- repeat{} gives BOMB
On 06-Nov-97 maechler@stat.math.ethz.ch wrote:
>I investigated some more:
> R_VISIBLE is set to 0 ``R_Visible = 0;''
> also in other places in eval.c :
>
> line C function
>
> 344: do_if
> 436: do_for
> 480: do_while
> 515: do_repeat
> 720: \
> 727: > do_set
> 738: /
> ^^^
>(line
2016 Sep 25
3
withAutoprint({ .... }) ?
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Sat, 24 Sep 2016 11:31:49 -0700 writes:
> Martin, did you post your code for withAutoprint() anywhere?
> Building withAutoprint() on top of source() definitely makes sense,
> unless, as Bill says, source() itself could provide the same feature.
I was really mainly asking
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, ...)
>>
2008 Feb 09
2
print.fitdistr buglet
Dear developers,
There's a small bug in print.fitdistr that can cause output to be printed
twice, but only if print is called explicitly:
> fit<-fitdistr(rt(1000,3),"t")
There were 11 warnings (use warnings() to see them)
> fit
m s df
-0.02181723 1.00145296 3.13723878
( 0.03865057) ( 0.03999447) ( 0.33298377)
> print(fit)
2020 Jul 22
3
Invisible names problem
I ran into strange behavior when removing names.
Two ways of removing names:
i <- rep(1:4, length.out=20000)
k <- c(a=1, b=2, c=3, d=4)
x1 <- unname(k[i])
x2 <- k[i]
x2 <- unname(x2)
Are they identical?
identical(x1,x2) # TRUE
but no
identical(serialize(x1,NULL),serialize(x2,NULL)) # FALSE
But problem is with serialization type 3, cause:
2023 Mar 24
1
make file.rename return invisible
Dear R Core devs,
I wonder if it makes sense to make function file.rename return invisible? This is not a big issue, but when running in RMarkdown or knitr, this function will print results. I have to manually call invisible to hide the output from showing in the final document:
```r
invisible(file.rename(...))
```
Otherwise knitr will print:
```
file.rename(...)
#> TRUE
```
If this
2019 May 21
2
print.<strorageMode>() not called when autoprinting
It also is a problem with storage.modes "integer" and "complex":
3.6.0> print.integer <- function(x,...) "integer vector"
3.6.0> 1:10
[1] 1 2 3 4 5 6 7 8 9 10
3.6.0> print(1:10)
[1] "integer vector"
3.6.0>
3.6.0> print.complex <- function(x, ...) "complex vector"
3.6.0> 1+2i
[1] 1+2i
3.6.0>