Dear r-devel,
In R `sign(0)` and `sign(-0)` both return `0` but negative zeroes do exist
in the sense that dividing by them gives `-Inf`
Complex numbers behave oddly with negative 0s, see below:
``` r
1 / Re(0 + 0i)
#> [1] Inf
1 / Im(0 + 0i)
#> [1] Inf
1 / Re(0 - 0i)
#> [1] Inf
1 / Im(0 - 0i) # n
29 mars 2024 à 16:25, Duncan Murdoch a
écrit :
> On 29/03/2024 10:52 a.m., Antoine Fabri wrote:
> > Dear r-devel,
> >
> > options() are basically global variables and they come with several
> issues:
> > * they're not really truly owned by a package aside from loose
Dear r-devel,
options() are basically global variables and they come with several issues:
* they're not really truly owned by a package aside from loose naming
conventions
* they're not validated
* their documentation is not standard, and they're often not documented at
all, it's hard to know what
Dear R-devel,
I periodically stumble on the same challenges when working with objects
with bracket S3 methods, and their length and names counterparts. I make
the distinction between what I call S3 subsetting using `[` and `[[` and
low level subsetting using `.subset()` and `.subset2()`.
When wor
Dear r-devel,
I was surprised to see that saveRDS() and readRDS() work quite well with
environments, see below:
```
z <- 3 # in global env
y <- new.env()
y$a <- 1
x <- new.env(parent = y)
x$b <- 2
saveRDS(x, "x.RDS")
# in a new session
x <- readRDS("x.RDS")
y <- parent.env(x)
x$b
#> [1] 2
y$a
#>
, for some reason I hadn't
found it, so that should fix my own issue here thanks a lot.
Le ven. 21 juil. 2023 à 16:18, Ivan Krylov a écrit :
> В Fri, 21 Jul 2023 15:14:09 +0200
> Antoine Fabri пишет:
>
> > On a closer look it seems like roxygen2 introduces those, when using
>
rt the first line to `\verb{c(c(1)}` and the second to
`\code{c(c(1))}`.
I've opened a ticket there FYI:
https://github.com/r-lib/roxygen2/issues/1503
--
>
> Message: 2
> Date: Thu, 20 Jul 2023 23:48:44 +0300
> From: Ivan Krylov
> To: Antoine Fabri
Dear r-devel,
I've tried tools::parseLatex() to parse some documentation files, it works
generally well but it it has some issues when "\\verb{}" is used.
```
tools::parseLatex("\\code{hello}")
# \code{hello}
tools::parseLatex("\\anything{hello}")
# \anything{hello}
tools::parseLatex("\\verb{hel
You could try {constructive} : https://github.com/cynkra/constructive/
Here's how it might help:
```
E <- new.env()
fun <- function(x) x
environment(fun) <- E
O <- list(
a = 1,
b = fun
)
# remotes::install_github("cynkra/constructive")
library(constructive)
construct(E)
#> constructive::env(
I just found this other discussion, with some more snark (who would have
thought this subject would be so slippery!) :
https://bugs.r-project.org/show_bug.cgi?id=17258
Duncan makes the argument that R's history shows the feature is not
absolutely necessary, but that's what make it a feature reques
Dear R-devel,
Packages don't allow for subfolders in R with a couple exceptions. We find
in "Writing R extensions" :
> The R and man subdirectories may contain OS-specific subdirectories named
unix or windows.
This is something I've seen discussed outside of the mailing list numerous
times, and
Let me expand a bit, I might have expressed myself poorly.
If there is a good reason for a warning I want a warning, and because I
take them seriously I don't want my console cluttered with those that can
be avoided. I strongly believe we should strive to make our code silent,
and I like my conso
Thanks and good point about unspecified behavior. The way it behaves now
(when it doesn't ignore) is more consistent with data.frame() though so I
prefer that to a "warn and ignore" behaviour:
data.frame(a = 1, b = 2, 3)
#> a b X3
#> 1 1 2 3
data.frame(a = 1, 2, 3)
#> a X2 X3
#> 1 1 2
Dear r-devel,
See below:
transform(data.frame(a = 1), 2, 3)
#> a
#> 1 1
transform(data.frame(a = 1), b=2, 3)
#> a b X3
#> 1 1 2 3
We need a small modification to make it work consistently, see below:
transform.data.frame <- function (`_data`, ...) {
e <- eval(substitute(list(..
Good points. I don't mind the terminology since target and current are the
names of the arguments. As the function is already designed to stop at the
first failing check we might not need to enumerate or count the mismatches,
instead we could have "`NA` found in `target` but not in `current` at
pos
dear r-devel,
This has probably been forever like this but is this satisfying ?
all.equal(c(1,NA,NA), c(1,NA,3))
#> [1] "'is.NA' value mismatch: 1 in current 2 in target"
is.NA() doesn't exist (is.na() does), and is.na() is never 1 or 2.
In this example it's obvious that we're counting missing
Dear r-devel,
When a package is only used in an argument definition, e.g :
f <- function(test = testthat::is_testing()) {
if (test) 1 else 2
}
R CMD CHECK gives us a note: "Namespace in Imports field not imported from:
'testthat'"
This incites me to remove the package from the Imports fi
Dear R devel,
as.list() can be used on functions, but not if they have a S3 class that
doesn't include "function".
See below :
```r
add1 <- function(x) x+1
as.list(add1)
#> $x
#>
#>
#> [[2]]
#> x + 1
class(add1) <- c("function", "foo")
as.list(add1)
#> $x
#>
#>
#> [[2]]
#> x + 1
class(add1)
Hi Gabe,
> [... ]
> Well, sure but that is because it happens to be a list with each element
> having length one. In which case, it really should not have been a list at
> all, and the fact that it was seems a deeper problem that should likely be
> resolved instead of treating the symptom, in my
Dear R-devel,
When trying to merge 2 data frames by an "id" column, with this column a
character in one of them, and a list of character in the other, merge
behaves differently depending which is given first.
Example :
```
df1 <- data.frame(a=1)
df2 <- data.frame(b=2)
df1$id <- "ID"
df2$id <- li
Dear R-devel,
The doc of exists, get and get0 is unambiguous, x should be an object given
as a character string. However these accept longer inputs. It can lead an
uncareful user to think these functions are vectorized when they're not,
and generally lets through bugs that one might have preferred
Dear r-devel,
The doc of bquote doesn't describe what inputs are allowed in `..()`, it
says :
*terms wrapped in ..() are evaluated and spliced into a call.*
I think "terms" is not clear enough, it might make the user think that
several arguments are possible, and the fact that `..()` (and `.()`
't
> match the srcref, both could be displayed along with file:line:column.
>
> ```
> #> f()
> #>
> #> 1 + f()
> ```
>
> Best,
> Lionel
>
>
> On 9/2/20, Antoine Fabri wrote:
> > Dear R-devel,
> >
> > I found this behavior
Dear R-devel,
I found this behavior disturbing, if `1 + f()` is called, `sys.call()`
called inside of `f` will return a quoted `f()` with a "srcref" that prints
"1 + f()".
I don't know which one is good but I don't think they can be correct at the
same time.
Here's a reproducible example:
f <-
k on things like
> foo <- function(x) {{ x }}
> ...)
>
> Best
> -k
>
> > ~G
>
> > On Wed, Aug 19, 2020 at 3:40 PM Antoine Fabri
> > wrote:
>
> >> Dear R-devel,
> >>
> >> utils::isS3stdGeneric tries to subset the body of the func
in R, implemented in the core. Tracing is
> implemented on top without specific support, it thus cannot do some
> things debugging can do.
>
> Tomas
>
>
> On 8/26/20 3:31 AM, Antoine Fabri wrote:
> > Apologies there is one line missing in my last email, the code should
Apologies there is one line missing in my last email, the code should be :
foo <- function() "hello"
trace2 <- function(fun) trace(fun, quote(print("!!!")))
trace2(foo) # <- THIS LINE WAS MISSING
base::fun
Best,
Antoine
Le mar. 25 août 2020 à 22:02, Antoine Fab
Dear R-devel,
I don't think this is expected :
foo <- function() "hello"
trace2 <- function(fun) trace(fun, quote(print("!!!")))
base::fun
# Object with tracing code, class "functionWithTrace"
# Original definition:
# function() "hello"
#
# ## (to see the tracing code, look at body(object))
`unt
Dear R-devel,
I have this debugging function that applies side effects, then acts like
browser once it's done :
meta_browser <- function() {
# ...
on.exit(eval.parent(quote(browser(
}
I can use it with a function such as fun1 below :
fun1 <- function(){
meta_browser()
print("hello")
Dear R-devel,
utils::isS3stdGeneric tries to subset the body of the function it's fed,
primitives don't like that because they don't have a body, identity doesn't
like it either because it's body is a symbol.
According to the doc, any function is a legal input.
See below:
identity
#> function (
Dear all,
model.frame behaves in a way I don't expect when both its formula and
subset argument are passed through a function call.
This works as expected:
model.frame(~wool, warpbreaks, breaks < 15)
#>wool
#> 14A
#> 23A
#> 29B
#> 50B
fun1 <- function(y) model.frame(~wool, wa
Dear rdevel,
See the example below :
x <- data.frame(a=1)
x$b <- data.frame(z=1)
y <- x
rbind(x,y)
# Error in `.rowNamesDF<-`(x, value = value) :
# duplicate 'row.names' are not allowed
# In addition: Warning message:
# non-unique value when setting 'row.names': ‘1’
I believe, that either it
Dear all,
`body<-` removes the class of the input function, it's undocumented and I
not what I would expect.
``` r
foo <- function() {1}
class(foo) <- "bar"
attr(foo, "class")
#> [1] "bar"
body(foo) <- 2
attr(foo, "class")
#> NULL
```
Best regards,
Antoine
[[alternative HTML version de
33 matches
Mail list logo